From c5c2bbebbf42048238ae884b2d5d3b75c1bada37 Mon Sep 17 00:00:00 2001 From: Chang Liu Date: Thu, 16 Jun 2022 12:04:37 -0700 Subject: [PATCH] Remove master keywords (#1886) Signed-off-by: cliu123 Signed-off-by: Stephen Crawford --- .../configuration/ClusterInfoHolder.java | 8 +-- .../privileges/SnapshotRestoreEvaluator.java | 2 +- .../resolver/IndexResolverReplacer.java | 2 +- .../org/opensearch/node/PluginAwareNode.java | 10 +-- .../AdvancedSecurityMigrationTests.java | 52 +++++++------- .../EncryptionInTransitMigrationTests.java | 4 +- .../integration/BasicAuditlogTest.java | 2 +- .../security/test/SingleClusterTest.java | 6 +- .../helper/cluster/ClusterConfiguration.java | 30 ++++---- .../test/helper/cluster/ClusterHelper.java | 69 ++++++++----------- .../test/helper/cluster/ClusterInfo.java | 2 +- tools/install_demo_configuration.sh | 8 --- 12 files changed, 86 insertions(+), 109 deletions(-) diff --git a/src/main/java/org/opensearch/security/configuration/ClusterInfoHolder.java b/src/main/java/org/opensearch/security/configuration/ClusterInfoHolder.java index 5bfb246352..b289eba0ef 100644 --- a/src/main/java/org/opensearch/security/configuration/ClusterInfoHolder.java +++ b/src/main/java/org/opensearch/security/configuration/ClusterInfoHolder.java @@ -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 @@ -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() { @@ -88,8 +88,8 @@ public Boolean getHas6xIndices() { return has6xIndices; } - public Boolean isLocalNodeElectedMaster() { - return isLocalNodeElectedMaster; + public Boolean isLocalNodeElectedClusterManager() { + return isLocalNodeElectedClusterManager; } public boolean isInitialized() { diff --git a/src/main/java/org/opensearch/security/privileges/SnapshotRestoreEvaluator.java b/src/main/java/org/opensearch/security/privileges/SnapshotRestoreEvaluator.java index 82fac2caa0..c457b42624 100644 --- a/src/main/java/org/opensearch/security/privileges/SnapshotRestoreEvaluator.java +++ b/src/main/java/org/opensearch/security/privileges/SnapshotRestoreEvaluator.java @@ -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(); } diff --git a/src/main/java/org/opensearch/security/resolver/IndexResolverReplacer.java b/src/main/java/org/opensearch/security/resolver/IndexResolverReplacer.java index ab8acee095..e0eddf9993 100644 --- a/src/main/java/org/opensearch/security/resolver/IndexResolverReplacer.java +++ b/src/main/java/org/opensearch/security/resolver/IndexResolverReplacer.java @@ -594,7 +594,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; } diff --git a/src/test/java/org/opensearch/node/PluginAwareNode.java b/src/test/java/org/opensearch/node/PluginAwareNode.java index 0ff1912879..39c93e6b8e 100644 --- a/src/test/java/org/opensearch/node/PluginAwareNode.java +++ b/src/test/java/org/opensearch/node/PluginAwareNode.java @@ -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... plugins) { + public PluginAwareNode(boolean clusterManagerEligible, final Settings preparedSettings, final Class... 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; } } diff --git a/src/test/java/org/opensearch/security/AdvancedSecurityMigrationTests.java b/src/test/java/org/opensearch/security/AdvancedSecurityMigrationTests.java index f3dea85df7..d9f2bd607a 100644 --- a/src/test/java/org/opensearch/security/AdvancedSecurityMigrationTests.java +++ b/src/test/java/org/opensearch/security/AdvancedSecurityMigrationTests.java @@ -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")); @@ -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; @@ -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); diff --git a/src/test/java/org/opensearch/security/EncryptionInTransitMigrationTests.java b/src/test/java/org/opensearch/security/EncryptionInTransitMigrationTests.java index 9442bc738c..b9679c217b 100644 --- a/src/test/java/org/opensearch/security/EncryptionInTransitMigrationTests.java +++ b/src/test/java/org/opensearch/security/EncryptionInTransitMigrationTests.java @@ -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"); diff --git a/src/test/java/org/opensearch/security/auditlog/integration/BasicAuditlogTest.java b/src/test/java/org/opensearch/security/auditlog/integration/BasicAuditlogTest.java index 8581a9a817..02cde14159 100644 --- a/src/test/java/org/opensearch/security/auditlog/integration/BasicAuditlogTest.java +++ b/src/test/java/org/opensearch/security/auditlog/integration/BasicAuditlogTest.java @@ -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)); } diff --git a/src/test/java/org/opensearch/security/test/SingleClusterTest.java b/src/test/java/org/opensearch/security/test/SingleClusterTest.java index 2f740cf2cc..39d0b595fc 100644 --- a/src/test/java/org/opensearch/security/test/SingleClusterTest.java +++ b/src/test/java/org/opensearch/security/test/SingleClusterTest.java @@ -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()); @@ -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 { diff --git a/src/test/java/org/opensearch/security/test/helper/cluster/ClusterConfiguration.java b/src/test/java/org/opensearch/security/test/helper/cluster/ClusterConfiguration.java index 8c93b5301c..05815c55f3 100644 --- a/src/test/java/org/opensearch/security/test/helper/cluster/ClusterConfiguration.java +++ b/src/test/java/org/opensearch/security/test/helper/cluster/ClusterConfiguration.java @@ -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)), @@ -82,20 +82,20 @@ public List getNodeSettings() { return Collections.unmodifiableList(nodeSettings); } - public List getMasterNodeSettings() { - return Collections.unmodifiableList(nodeSettings.stream().filter(a->a.masterNode).collect(Collectors.toList())); + public List getClusterManagerNodeSettings() { + return Collections.unmodifiableList(nodeSettings.stream().filter(a->a.clusterManagerNode).collect(Collectors.toList())); } - public List getNonMasterNodeSettings() { - return Collections.unmodifiableList(nodeSettings.stream().filter(a->!a.masterNode).collect(Collectors.toList())); + public List 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() { @@ -103,22 +103,22 @@ public int getDataNodes() { } 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> 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> additionalPlugins) { - this(masterNode, dataNode); + public NodeSettings(boolean clusterManagerNode, boolean dataNode, List> additionalPlugins) { + this(clusterManagerNode, dataNode); this.plugins.addAll(additionalPlugins); } diff --git a/src/test/java/org/opensearch/security/test/helper/cluster/ClusterHelper.java b/src/test/java/org/opensearch/security/test/helper/cluster/ClusterHelper.java index 5dd8f8c9e5..72360a5712 100644 --- a/src/test/java/org/opensearch/security/test/helper/cluster/ClusterHelper.java +++ b/src/test/java/org/opensearch/security/test/helper/cluster/ClusterHelper.java @@ -130,34 +130,33 @@ public final synchronized ClusterInfo startCluster(final NodeSettingsSupplier no final SortedSet freePorts = SocketUtils.findAvailableTcpPorts(internalNodeSettings.size()*2, min, max); assert freePorts.size() == internalNodeSettings.size()*2; - final SortedSet tcpMasterPortsOnly = new TreeSet(); + final SortedSet tcpClusterManagerPortsOnly = new TreeSet(); final SortedSet tcpAllPorts = new TreeSet(); - freePorts.stream().limit(clusterConfiguration.getMasterNodes()).forEach(el->tcpMasterPortsOnly.add(el)); + freePorts.stream().limit(clusterConfiguration.getClusterManagerNodes()).forEach(el->tcpClusterManagerPortsOnly.add(el)); freePorts.stream().limit(internalNodeSettings.size()).forEach(el->tcpAllPorts.add(el)); - //final Iterator tcpPortsMasterOnlyIt = tcpMasterPortsOnly.iterator(); final Iterator tcpPortsAllIt = tcpAllPorts.iterator(); final SortedSet httpPorts = new TreeSet(); freePorts.stream().skip(internalNodeSettings.size()).limit(internalNodeSettings.size()).forEach(el->httpPorts.add(el)); final Iterator httpPortsIt = httpPorts.iterator(); - System.out.println("tcpMasterPorts: "+tcpMasterPortsOnly+"/tcpAllPorts: "+tcpAllPorts+"/httpPorts: "+httpPorts+" for ("+min+"-"+max+") fork "+forkNumber); + System.out.println("tcpClusterManagerPorts: "+tcpClusterManagerPortsOnly+"/tcpAllPorts: "+tcpAllPorts+"/httpPorts: "+httpPorts+" for ("+min+"-"+max+") fork "+forkNumber); final CountDownLatch latch = new CountDownLatch(internalNodeSettings.size()); final AtomicReference err = new AtomicReference(); - List internalMasterNodeSettings = clusterConfiguration.getMasterNodeSettings(); - List internalNonMasterNodeSettings = clusterConfiguration.getNonMasterNodeSettings(); + List internalClusterManagerNodeSettings = clusterConfiguration.getClusterManagerNodeSettings(); + List internalNonClusterManagerNodeSettings = clusterConfiguration.getNonClusterManagerNodeSettings(); int nodeNumCounter = internalNodeSettings.size(); - for (int i = 0; i < internalMasterNodeSettings.size(); i++) { - NodeSettings setting = internalMasterNodeSettings.get(i); + for (int i = 0; i < internalClusterManagerNodeSettings.size(); i++) { + NodeSettings setting = internalClusterManagerNodeSettings.get(i); int nodeNum = nodeNumCounter--; - PluginAwareNode node = new PluginAwareNode(setting.masterNode, - getMinimumNonSecurityNodeSettingsBuilder(nodeNum, setting.masterNode, setting.dataNode, internalNodeSettings.size(), tcpMasterPortsOnly, tcpPortsAllIt.next(), httpPortsIt.next()) + PluginAwareNode node = new PluginAwareNode(setting.clusterManagerNode, + getMinimumNonSecurityNodeSettingsBuilder(nodeNum, setting.clusterManagerNode, setting.dataNode, internalNodeSettings.size(), tcpClusterManagerPortsOnly, tcpPortsAllIt.next(), httpPortsIt.next()) .put(nodeSettingsSupplier == null ? Settings.Builder.EMPTY_SETTINGS : nodeSettingsSupplier.get(nodeNum)).build(), setting.getPlugins()); System.out.println(node.settings()); @@ -179,11 +178,11 @@ public void run() { opensearchNodes.add(node); } - for (int i = 0; i < internalNonMasterNodeSettings.size(); i++) { - NodeSettings setting = internalNonMasterNodeSettings.get(i); + for (int i = 0; i < internalNonClusterManagerNodeSettings.size(); i++) { + NodeSettings setting = internalNonClusterManagerNodeSettings.get(i); int nodeNum = nodeNumCounter--; - PluginAwareNode node = new PluginAwareNode(setting.masterNode, - getMinimumNonSecurityNodeSettingsBuilder(nodeNum, setting.masterNode, setting.dataNode, internalNodeSettings.size(), tcpMasterPortsOnly, tcpPortsAllIt.next(), httpPortsIt.next()) + PluginAwareNode node = new PluginAwareNode(setting.clusterManagerNode, + getMinimumNonSecurityNodeSettingsBuilder(nodeNum, setting.clusterManagerNode, setting.dataNode, internalNodeSettings.size(), tcpClusterManagerPortsOnly, tcpPortsAllIt.next(), httpPortsIt.next()) .put(nodeSettingsSupplier == null ? Settings.Builder.EMPTY_SETTINGS : nodeSettingsSupplier.get(nodeNum)).build(), setting.getPlugins()); System.out.println(node.settings()); @@ -216,7 +215,7 @@ public void run() { ClusterInfo cInfo = waitForCluster(ClusterHealthStatus.GREEN, TimeValue.timeValueSeconds(timeout), nodes == null?opensearchNodes.size():nodes.intValue()); cInfo.numNodes = internalNodeSettings.size(); cInfo.clustername = clustername; - cInfo.tcpMasterPortsOnly = tcpMasterPortsOnly.stream().map(s->"127.0.0.1:"+s).collect(Collectors.toList()); + cInfo.tcpClusterManagerPortsOnly = tcpClusterManagerPortsOnly.stream().map(s->"127.0.0.1:"+s).collect(Collectors.toList()); final String defaultTemplate = "{\n" + " \"index_patterns\": [\"*\"],\n" + @@ -243,11 +242,11 @@ public final void stopCluster() throws Exception { } private void closeAllNodes() throws Exception { - //close non master nodes - opensearchNodes.stream().filter(n->!n.isMasterEligible()).forEach(ClusterHelper::closeNode); + //close non cluster manager nodes + opensearchNodes.stream().filter(n->!n.isClusterManagerEligible()).forEach(ClusterHelper::closeNode); - //close master nodes - opensearchNodes.stream().filter(n->n.isMasterEligible()).forEach(ClusterHelper::closeNode); + //close cluster manager nodes + opensearchNodes.stream().filter(n->n.isClusterManagerEligible()).forEach(ClusterHelper::closeNode); opensearchNodes.clear(); clusterState = ClusterState.STOPPED; } @@ -293,14 +292,14 @@ public ClusterInfo waitForCluster(final ClusterHealthStatus status, final TimeVa final List nodes = res.getNodes(); - final List masterNodes = nodes.stream().filter(n->n.getNode().getRoles().contains(DiscoveryNodeRole.MASTER_ROLE)).collect(Collectors.toList()); - final List dataNodes = nodes.stream().filter(n->n.getNode().getRoles().contains(DiscoveryNodeRole.DATA_ROLE) && !n.getNode().getRoles().contains(DiscoveryNodeRole.MASTER_ROLE)).collect(Collectors.toList()); + final List clusterManagerNodes = nodes.stream().filter(n->n.getNode().getRoles().contains(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE)).collect(Collectors.toList()); + final List dataNodes = nodes.stream().filter(n->n.getNode().getRoles().contains(DiscoveryNodeRole.DATA_ROLE) && !n.getNode().getRoles().contains(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE)).collect(Collectors.toList()); // Sorting the nodes so that the node receiving the http requests is always deterministic dataNodes.sort(Comparator.comparing(nodeInfo -> nodeInfo.getNode().getName())); - final List clientNodes = nodes.stream().filter(n->!n.getNode().getRoles().contains(DiscoveryNodeRole.MASTER_ROLE) && !n.getNode().getRoles().contains(DiscoveryNodeRole.DATA_ROLE)).collect(Collectors.toList()); + final List clientNodes = nodes.stream().filter(n->!n.getNode().getRoles().contains(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE) && !n.getNode().getRoles().contains(DiscoveryNodeRole.DATA_ROLE)).collect(Collectors.toList()); - for (NodeInfo nodeInfo: masterNodes) { + for (NodeInfo nodeInfo: clusterManagerNodes) { final TransportInfo transportInfo = nodeInfo.getInfo(TransportInfo.class); final TransportAddress transportAddress = transportInfo.getAddress().publishAddress(); clusterInfo.nodePort = transportAddress.getPort(); @@ -351,39 +350,25 @@ public ClusterInfo waitForCluster(final ClusterHealthStatus status, final TimeVa } // @formatter:off - private Settings.Builder getMinimumNonSecurityNodeSettingsBuilder(final int nodenum, final boolean masterNode, - final boolean dataNode, int nodeCount, SortedSet masterTcpPorts, /*SortedSet nonMasterTcpPorts,*/ int tcpPort, int httpPort) { + private Settings.Builder getMinimumNonSecurityNodeSettingsBuilder(final int nodenum, final boolean clusterManagerNode, + final boolean dataNode, int nodeCount, SortedSet clusterManagerTcpPorts, int tcpPort, int httpPort) { return Settings.builder() .put("node.name", "node_"+clustername+ "_num" + nodenum) .put("node.data", dataNode) - .put("node.master", masterNode) + .put("node.master", clusterManagerNode) .put("cluster.name", clustername) .put("path.data", "./target/data/"+clustername+"/data") .put("path.logs", "./target/data/"+clustername+"/logs") .put("node.max_local_storage_nodes", nodeCount) - //.put("discovery.zen.minimum_master_nodes", minMasterNodes(masterTcpPorts.size())) - .putList("cluster.initial_cluster_manager_nodes", masterTcpPorts.stream().map(s->"127.0.0.1:"+s).collect(Collectors.toList())) - //.put("discovery.zen.no_master_block", "all") - //.put("discovery.zen.fd.ping_timeout", "5s") + .putList("cluster.initial_cluster_manager_nodes", clusterManagerTcpPorts.stream().map(s->"127.0.0.1:"+s).collect(Collectors.toList())) .put("discovery.initial_state_timeout","8s") - .putList("discovery.seed_hosts", masterTcpPorts.stream().map(s->"127.0.0.1:"+s).collect(Collectors.toList())) + .putList("discovery.seed_hosts", clusterManagerTcpPorts.stream().map(s->"127.0.0.1:"+s).collect(Collectors.toList())) .put("transport.tcp.port", tcpPort) .put("http.port", httpPort) - //.put("http.enabled", true) .put("http.cors.enabled", true) .put("path.home", "./target"); } - // @formatter:on - - /*private int minMasterNodes(int masterEligibleNodes) { - if(masterEligibleNodes <= 0) { - throw new IllegalArgumentException("no master eligible nodes"); - } - - return (masterEligibleNodes/2) + 1; - - }*/ private enum ClusterState{ UNINITIALIZED, diff --git a/src/test/java/org/opensearch/security/test/helper/cluster/ClusterInfo.java b/src/test/java/org/opensearch/security/test/helper/cluster/ClusterInfo.java index 2231797185..bb59450752 100644 --- a/src/test/java/org/opensearch/security/test/helper/cluster/ClusterInfo.java +++ b/src/test/java/org/opensearch/security/test/helper/cluster/ClusterInfo.java @@ -40,5 +40,5 @@ public class ClusterInfo { public String nodeHost; public int nodePort; public String clustername; - public List tcpMasterPortsOnly; + public List tcpClusterManagerPortsOnly; } diff --git a/tools/install_demo_configuration.sh b/tools/install_demo_configuration.sh index aa7c736b47..287ded080c 100755 --- a/tools/install_demo_configuration.sh +++ b/tools/install_demo_configuration.sh @@ -391,14 +391,6 @@ else fi fi -#discovery.zen.minimum_master_nodes -#if $SUDO_CMD grep --quiet -i "^discovery.zen.minimum_master_nodes" "$OPENSEARCH_CONF_FILE"; then -# : #already present -#else -# echo "discovery.zen.minimum_master_nodes: 1" | $SUDO_CMD tee -a "$OPENSEARCH_CONF_FILE" > /dev/null -#fi - -#node.max_local_storage_nodes if $SUDO_CMD grep --quiet -i "^node.max_local_storage_nodes" "$OPENSEARCH_CONF_FILE"; then : #already present else