Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove master keywords #1886

Merged
merged 2 commits into from
Jun 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class ClusterInfoHolder implements ClusterStateListener {
private volatile Boolean has6xNodes = null;
private volatile Boolean has6xIndices = null;
private volatile DiscoveryNodes nodes = null;
private volatile Boolean isLocalNodeElectedMaster = null;
private volatile Boolean isLocalNodeElectedClusterManager = null;
private volatile boolean initialized;

@Override
Expand Down Expand Up @@ -77,7 +77,7 @@ public void clusterChanged(ClusterChangedEvent event) {
initialized = true;
}

isLocalNodeElectedMaster = event.localNodeMaster()?Boolean.TRUE:Boolean.FALSE;
isLocalNodeElectedClusterManager = event.localNodeMaster()?Boolean.TRUE:Boolean.FALSE;
}

public Boolean getHas6xNodes() {
Expand All @@ -88,8 +88,8 @@ public Boolean getHas6xIndices() {
return has6xIndices;
}

public Boolean isLocalNodeElectedMaster() {
return isLocalNodeElectedMaster;
public Boolean isLocalNodeElectedClusterManager() {
return isLocalNodeElectedClusterManager;
}

public boolean isInitialized() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public PrivilegesEvaluatorResponse evaluate(final ActionRequest request, final T
}


if (clusterInfoHolder.isLocalNodeElectedMaster() == Boolean.FALSE) {
if (clusterInfoHolder.isLocalNodeElectedClusterManager() == Boolean.FALSE) {
presponse.allowed = true;
return presponse.markComplete();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ private boolean getOrReplaceAllIndices(final Object request, final IndicesProvid
}
} else if(request instanceof RestoreSnapshotRequest) {

if(clusterInfoHolder.isLocalNodeElectedMaster() == Boolean.FALSE) {
if(clusterInfoHolder.isLocalNodeElectedClusterManager() == Boolean.FALSE) {
return true;
}

Expand Down
10 changes: 5 additions & 5 deletions src/test/java/org/opensearch/node/PluginAwareNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@

public class PluginAwareNode extends Node {

private final boolean masterEligible;
private final boolean clusterManagerEligible;

@SafeVarargs
public PluginAwareNode(boolean masterEligible, final Settings preparedSettings, final Class<? extends Plugin>... plugins) {
public PluginAwareNode(boolean clusterManagerEligible, final Settings preparedSettings, final Class<? extends Plugin>... plugins) {
super(InternalSettingsPreparer.prepareEnvironment(preparedSettings, Collections.emptyMap(), null, () -> System.getenv("HOSTNAME")), Arrays.asList(plugins), true);
this.masterEligible = masterEligible;
this.clusterManagerEligible = clusterManagerEligible;
}


public boolean isMasterEligible() {
return masterEligible;
public boolean isClusterManagerEligible() {
return clusterManagerEligible;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,136 +40,136 @@ public void cleanupAfter() {
}

/**
* 2 data nodes are adv sec enabled. 1 master node and 1 data node are SSL only.
* 2 data nodes are adv sec enabled. 1 cluster manager node and 1 data node are SSL only.
* Rest request lands on SSL only data node
* @throws Exception
*/
@Test
public void testPluginEnabledDataNodeWithSSlOnlyMasterNode_ReqOnSSLNode() throws Exception {
public void testPluginEnabledDataNodeWithSSlOnlyClusterManagerNode_ReqOnSSLNode() throws Exception {
final Settings advSecSettings = getAdvSecSettings().build();
final Settings sslOnlySettings = getSSLOnlyModeSettings().build();

setupGenericNodes(Arrays.asList(sslOnlySettings, advSecSettings, advSecSettings, sslOnlySettings),
Arrays.asList(true, false, false, true), ClusterConfiguration.ONE_MASTER_THREE_DATA);
Arrays.asList(true, false, false, true), ClusterConfiguration.ONE_CLUSTER_MANAGER_THREE_DATA);
Thread.sleep(10000);

commonTestsForAdvancedSecurityMigration(nonSslRestHelper(), null);
}

/**
* 2 data nodes are adv sec enabled. 1 master node and 1 data node are SSL only.
* 2 data nodes are adv sec enabled. 1 cluster manager node and 1 data node are SSL only.
* Rest request lands on adv sec data node
* @throws Exception
*/
@Test
public void testPluginEnabledDataNodeWithSSlOnlyMasterNode_ReqOnAdvSecNode() throws Exception {
public void testPluginEnabledDataNodeWithSSlOnlyClusterManagerNode_ReqOnAdvSecNode() throws Exception {
final Settings advSecSettings = getAdvSecSettings().build();
final Settings sslOnlySettings = getSSLOnlyModeSettings().build();

setupGenericNodes(Arrays.asList(advSecSettings, sslOnlySettings, advSecSettings, sslOnlySettings),
Arrays.asList(false, true, false, true), ClusterConfiguration.ONE_MASTER_THREE_DATA);
Arrays.asList(false, true, false, true), ClusterConfiguration.ONE_CLUSTER_MANAGER_THREE_DATA);
Thread.sleep(10000);

commonTestsForAdvancedSecurityMigration(nonSslRestHelper(), encodeBasicHeader("admin", "admin"));
}

/**
* 1 Master node and 1 Data node is adv sec enabled. 2 Data nodes are SSL only.
* 1 cluster manager node and 1 Data node is adv sec enabled. 2 Data nodes are SSL only.
* Rest request lands on ssl only data node
* @throws Exception
*/
@Test
public void testPluginEnabledMasterNodeWithSSlOnlyDataNode_ReqOnSSLNode() throws Exception {
public void testPluginEnabledClusterManagerNodeWithSSlOnlyDataNode_ReqOnSSLNode() throws Exception {
final Settings advSecSettings = getAdvSecSettings().build();
final Settings sslOnlySettings = getSSLOnlyModeSettings().build();

setupGenericNodes(Arrays.asList(sslOnlySettings, sslOnlySettings, advSecSettings, advSecSettings),
Arrays.asList(true, true, false, false), ClusterConfiguration.ONE_MASTER_THREE_DATA);
Arrays.asList(true, true, false, false), ClusterConfiguration.ONE_CLUSTER_MANAGER_THREE_DATA);
Thread.sleep(10000);

commonTestsForAdvancedSecurityMigration(nonSslRestHelper(),null);
}

/**
* 1 Master node and 1 Data node is adv sec enabled. 2 Data nodes are SSL only.
* 1 cluster manager node and 1 Data node is adv sec enabled. 2 Data nodes are SSL only.
* Rest request lands on adv sec data node
* @throws Exception
*/
@Test
public void testPluginEnabledMasterNodeWithSSlOnlyDataNode_ReqOnAdvSecNode() throws Exception {
public void testPluginEnabledClusterManagerNodeWithSSlOnlyDataNode_ReqOnAdvSecNode() throws Exception {
final Settings advSecSettings = getAdvSecSettings().build();
final Settings sslOnlySettings = getSSLOnlyModeSettings().build();

setupGenericNodes(Arrays.asList(advSecSettings, sslOnlySettings, sslOnlySettings, advSecSettings),
Arrays.asList(false, true, true, false), ClusterConfiguration.ONE_MASTER_THREE_DATA);
Arrays.asList(false, true, true, false), ClusterConfiguration.ONE_CLUSTER_MANAGER_THREE_DATA);
Thread.sleep(10000);

commonTestsForAdvancedSecurityMigration(nonSslRestHelper(), encodeBasicHeader("admin", "admin"));
}

/**
* 2 Data nodes are adv sec enabled. 1 Master node and 1 Data node are plugin disabled.
* 2 Data nodes are adv sec enabled. 1 cluster manager node and 1 Data node are plugin disabled.
* Rest request lands on plugin disabled node
* @throws Exception
*/
@Test
public void testPluginEnabledDataNodeWithDisabledMasterNode_ReqOnDisabledNode() throws Exception {
public void testPluginEnabledDataNodeWithDisabledClusterManagerNode_ReqOnDisabledNode() throws Exception {
final Settings advSecSettings = getAdvSecSettingsDualMode().build();
final Settings disabledSettings = getDisabledSettings().build();

setupGenericNodes(Arrays.asList(disabledSettings, advSecSettings, advSecSettings, disabledSettings),
Arrays.asList(false, false, false, false), ClusterConfiguration.ONE_MASTER_THREE_DATA);
Arrays.asList(false, false, false, false), ClusterConfiguration.ONE_CLUSTER_MANAGER_THREE_DATA);
Thread.sleep(10000);

commonTestsForAdvancedSecurityMigration(nonSslRestHelper(),null);
}

/**
* 2 Data nodes are adv sec enabled. 1 Master node and 1 Data node are plugin disabled.
* 2 Data nodes are adv sec enabled. 1 cluster manager node and 1 Data node are plugin disabled.
* Rest request lands on adv sec data node
* @throws Exception
*/
@Test
public void testPluginEnabledDataNodeWithDisabledMasterNode_ReqOnAdvSecNode() throws Exception {
public void testPluginEnabledDataNodeWithDisabledClusterManagerNode_ReqOnAdvSecNode() throws Exception {
final Settings advSecSettings = getAdvSecSettingsDualMode().build();
final Settings disabledSettings = getDisabledSettings().build();

setupGenericNodes(Arrays.asList(advSecSettings, disabledSettings, advSecSettings, disabledSettings),
Arrays.asList(false, false, false, false), ClusterConfiguration.ONE_MASTER_THREE_DATA);
Arrays.asList(false, false, false, false), ClusterConfiguration.ONE_CLUSTER_MANAGER_THREE_DATA);
Thread.sleep(10000);

commonTestsForAdvancedSecurityMigration(nonSslRestHelper(), encodeBasicHeader("admin", "admin"));
}

/**
* 1 Master node and 1 Data node are adv sec enabled. 2 Data nodes are plugin disabled.
* 1 cluster manager node and 1 Data node are adv sec enabled. 2 Data nodes are plugin disabled.
* Rest request lands on plugin disabled node
* @throws Exception
*/
@Test
public void testPluginEnabledMasterNodeWithDisabledDataNode_ReqOnDisabledNode() throws Exception {
public void testPluginEnabledClusterManagerNodeWithDisabledDataNode_ReqOnDisabledNode() throws Exception {
final Settings advSecSettings = getAdvSecSettingsDualMode().build();
final Settings disabledSettings = getDisabledSettings().build();

setupGenericNodes(Arrays.asList(disabledSettings, disabledSettings, advSecSettings, advSecSettings),
Arrays.asList(false, false, false, false), ClusterConfiguration.ONE_MASTER_THREE_DATA);
Arrays.asList(false, false, false, false), ClusterConfiguration.ONE_CLUSTER_MANAGER_THREE_DATA);
Thread.sleep(10000);

commonTestsForAdvancedSecurityMigration(nonSslRestHelper(), null);
}

/**
* 1 Master node and 2 Data nodes are adv sec enabled. 1 Data node is plugin disabled.
* 1 cluster manager node and 2 Data nodes are adv sec enabled. 1 Data node is plugin disabled.
* Rest request lands on plugin adv sec node
* @throws Exception
*/
@Test
public void testPluginEnabledMasterNodeWithDisabledDataNode_ReqOnAdvSecNode() throws Exception {
public void testPluginEnabledClusterManagerNodeWithDisabledDataNode_ReqOnAdvSecNode() throws Exception {
final Settings advSecSettings = getAdvSecSettingsDualMode().build();
final Settings disabledSettings = getDisabledSettings().build();

setupGenericNodes(Arrays.asList(advSecSettings, disabledSettings, advSecSettings, advSecSettings),
Arrays.asList(false, false, false, false), ClusterConfiguration.ONE_MASTER_THREE_DATA);
Arrays.asList(false, false, false, false), ClusterConfiguration.ONE_CLUSTER_MANAGER_THREE_DATA);
Thread.sleep(10000);

commonTestsForAdvancedSecurityMigration(nonSslRestHelper(), encodeBasicHeader("admin", "admin"));
Expand All @@ -183,7 +183,7 @@ public void testWithPassiveAuthDisabled() throws Exception {
final Settings sslOnlySettings = getSSLOnlyModeSettings().build();

setupGenericNodes(Arrays.asList(sslOnlySettings, sslOnlySettings, advSecSettings, advSecSettings),
Arrays.asList(true, true, false, false), ClusterConfiguration.ONE_MASTER_THREE_DATA);
Arrays.asList(true, true, false, false), ClusterConfiguration.ONE_CLUSTER_MANAGER_THREE_DATA);
Thread.sleep(10000);

RestHelper.HttpResponse res;
Expand All @@ -201,7 +201,7 @@ public void testWithPassiveAuthDisabledDynamic() throws Exception {
final Settings disabledSettings = getDisabledSettings().build();

setupGenericNodes(Arrays.asList(disabledSettings, disabledSettings, advSecSettings, advSecSettings),
Arrays.asList(false, false, false, false), ClusterConfiguration.ONE_MASTER_THREE_DATA);
Arrays.asList(false, false, false, false), ClusterConfiguration.ONE_CLUSTER_MANAGER_THREE_DATA);

Thread.sleep(5*1000);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ private void testSslOnlyMode(boolean dualModeEnabled) throws Exception {
}

@Test
public void testSslOnlyModeDualModeWithNonSSLMasterNode() throws Exception {
public void testSslOnlyModeDualModeWithNonSSLClusterManagerNode() throws Exception {
final Settings settings = Settings.builder()
.put(ConfigConstants.SECURITY_SSL_ONLY, true)
.put(ConfigConstants.SECURITY_CONFIG_SSL_DUAL_MODE_ENABLED, true)
.build();
setupSslOnlyModeWithMasterNodeWithoutSSL(settings);
setupSslOnlyModeWithClusterManagerNodeWithoutSSL(settings);
final RestHelper rh = nonSslRestHelper();

HttpResponse res = rh.executeGetRequest("/_search");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ public void testUpdateSettings() throws Exception {
Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("AUTHENTICATED"));
Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("cluster:admin/settings/update"));
Assert.assertTrue(TestAuditlogImpl.sb.toString().contains("indices.recovery.*"));
//may vary because we log may hit master directly or not
//may vary because we log may hit cluster manager directly or not
Assert.assertTrue(TestAuditlogImpl.messages.size() > 1);
Assert.assertTrue(validateMsgs(TestAuditlogImpl.messages));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

public abstract class SingleClusterTest extends AbstractSecurityUnitTest {

private static final int DEFAULT_MASTER_NODE_NUM = 3;
private static final int DEFAULT_CLUSTER_MANAGER_NODE_NUM = 3;
private static final int DEFAULT_FIRST_DATA_NODE_NUM = 2;

protected ClusterHelper clusterHelper = new ClusterHelper("utest_n"+num.incrementAndGet()+"_f"+System.getProperty("forkno")+"_t"+System.nanoTime());
Expand Down Expand Up @@ -112,10 +112,10 @@ protected void setupSslOnlyMode(Settings nodeOverride) throws Exception {
clusterInfo = clusterHelper.startCluster(minimumSecuritySettingsSslOnly(nodeOverride), ClusterConfiguration.DEFAULT);
}

protected void setupSslOnlyModeWithMasterNodeWithoutSSL(Settings nodeOverride) throws Exception {
protected void setupSslOnlyModeWithClusterManagerNodeWithoutSSL(Settings nodeOverride) throws Exception {
Assert.assertNull("No cluster", clusterInfo);
clusterInfo = clusterHelper.startCluster(minimumSecuritySettingsSslOnlyWithOneNodeNonSSL(nodeOverride,
DEFAULT_MASTER_NODE_NUM), ClusterConfiguration.DEFAULT_MASTER_WITHOUT_SECURITY_PLUGIN);
DEFAULT_CLUSTER_MANAGER_NODE_NUM), ClusterConfiguration.DEFAULT_CLUSTER_MANAGER_WITHOUT_SECURITY_PLUGIN);
}

protected void setupSslOnlyModeWithDataNodeWithoutSSL(Settings nodeOverride) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@
import org.opensearch.transport.Netty4Plugin;

public enum ClusterConfiguration {
//first one needs to be a master
//first one needs to be a cluster manager
//HUGE(new NodeSettings(true, false, false), new NodeSettings(true, false, false), new NodeSettings(true, false, false), new NodeSettings(false, true,false), new NodeSettings(false, true, false)),

//3 nodes (1m, 2d)
DEFAULT(new NodeSettings(true, false), new NodeSettings(false, true), new NodeSettings(false, true)),

//2 nodes (1m, 3d)
ONE_MASTER_THREE_DATA(new NodeSettings(true, false), new NodeSettings(false, true), new NodeSettings(false, true), new NodeSettings(false, true)),
ONE_CLUSTER_MANAGER_THREE_DATA(new NodeSettings(true, false), new NodeSettings(false, true), new NodeSettings(false, true), new NodeSettings(false, true)),

DEFAULT_MASTER_WITHOUT_SECURITY_PLUGIN(new NodeSettings(true, false)
DEFAULT_CLUSTER_MANAGER_WITHOUT_SECURITY_PLUGIN(new NodeSettings(true, false)
.removePluginIfPresent(OpenSearchSecurityPlugin.class)
, new NodeSettings(false, true)
, new NodeSettings(false, true)),
Expand Down Expand Up @@ -82,43 +82,43 @@ public List<NodeSettings> getNodeSettings() {
return Collections.unmodifiableList(nodeSettings);
}

public List<NodeSettings> getMasterNodeSettings() {
return Collections.unmodifiableList(nodeSettings.stream().filter(a->a.masterNode).collect(Collectors.toList()));
public List<NodeSettings> getClusterManagerNodeSettings() {
return Collections.unmodifiableList(nodeSettings.stream().filter(a->a.clusterManagerNode).collect(Collectors.toList()));
}

public List<NodeSettings> getNonMasterNodeSettings() {
return Collections.unmodifiableList(nodeSettings.stream().filter(a->!a.masterNode).collect(Collectors.toList()));
public List<NodeSettings> getNonClusterManagerNodeSettings() {
return Collections.unmodifiableList(nodeSettings.stream().filter(a->!a.clusterManagerNode).collect(Collectors.toList()));
}

public int getNodes() {
return nodeSettings.size();
}

public int getMasterNodes() {
return (int) nodeSettings.stream().filter(a->a.masterNode).count();
public int getClusterManagerNodes() {
return (int) nodeSettings.stream().filter(a->a.clusterManagerNode).count();
}

public int getDataNodes() {
return (int) nodeSettings.stream().filter(a->a.dataNode).count();
}

public int getClientNodes() {
return (int) nodeSettings.stream().filter(a->!a.masterNode && !a.dataNode).count();
return (int) nodeSettings.stream().filter(a->!a.clusterManagerNode && !a.dataNode).count();
}

public static class NodeSettings {
public boolean masterNode;
public boolean clusterManagerNode;
public boolean dataNode;
public List<Class<? extends Plugin>> plugins = Lists.newArrayList(Netty4Plugin.class, OpenSearchSecurityPlugin.class, MatrixAggregationPlugin.class, MustachePlugin.class, ParentJoinPlugin.class, PercolatorPlugin.class, ReindexPlugin.class);

public NodeSettings(boolean masterNode, boolean dataNode) {
public NodeSettings(boolean clusterManagerNode, boolean dataNode) {
super();
this.masterNode = masterNode;
this.clusterManagerNode = clusterManagerNode;
this.dataNode = dataNode;
}

public NodeSettings(boolean masterNode, boolean dataNode, List<Class<? extends Plugin>> additionalPlugins) {
this(masterNode, dataNode);
public NodeSettings(boolean clusterManagerNode, boolean dataNode, List<Class<? extends Plugin>> additionalPlugins) {
this(clusterManagerNode, dataNode);
this.plugins.addAll(additionalPlugins);
}

Expand Down
Loading