From 4ea1231b1041f99e8b4cc11b86a3dc6521edd6b8 Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Mon, 14 Mar 2022 11:33:32 -0700 Subject: [PATCH 01/13] Deprecate setting cluster.initial_master_nodes, and add setting cluster.initial_cluster_manager_nodes Signed-off-by: Tianli Feng --- .../discovery/ClusterDisruptionIT.java | 2 +- .../gateway/RecoveryFromGatewayIT.java | 4 +- .../opensearch/bootstrap/BootstrapChecks.java | 4 +- .../coordination/ClusterBootstrapService.java | 19 +++-- .../ClusterFormationFailureHelper.java | 8 +- .../common/settings/ClusterSettings.java | 3 +- .../bootstrap/BootstrapChecksTests.java | 2 +- ...erBootstrapServiceRenamedSettingTests.java | 84 +++++++++++++++++++ .../ClusterBootstrapServiceTests.java | 51 +++++------ .../ClusterFormationFailureHelperTests.java | 4 +- .../indices/IndicesServiceCloseTests.java | 4 +- .../snapshots/SnapshotResiliencyTests.java | 4 +- .../AbstractCoordinatorTestCase.java | 4 +- .../opensearch/test/InternalTestCluster.java | 17 ++-- .../test/OpenSearchSingleNodeTestCase.java | 4 +- 15 files changed, 157 insertions(+), 57 deletions(-) create mode 100644 server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceRenamedSettingTests.java diff --git a/server/src/internalClusterTest/java/org/opensearch/discovery/ClusterDisruptionIT.java b/server/src/internalClusterTest/java/org/opensearch/discovery/ClusterDisruptionIT.java index 53002a38c3a9d..ceec1315a9d59 100644 --- a/server/src/internalClusterTest/java/org/opensearch/discovery/ClusterDisruptionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/discovery/ClusterDisruptionIT.java @@ -422,7 +422,7 @@ public boolean clearData(String nodeName) { @Override public Settings onNodeStopped(String nodeName) { return Settings.builder() - .put(ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.getKey(), nodeName) + .put(ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), nodeName) /* * the data node might join while the master is still not fully established as master just yet and bypasses the join * validation that is done before adding the node to the cluster. Only the join validation when handling the publish diff --git a/server/src/internalClusterTest/java/org/opensearch/gateway/RecoveryFromGatewayIT.java b/server/src/internalClusterTest/java/org/opensearch/gateway/RecoveryFromGatewayIT.java index 612abee7dbf5b..ebe13a093c0fa 100644 --- a/server/src/internalClusterTest/java/org/opensearch/gateway/RecoveryFromGatewayIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/gateway/RecoveryFromGatewayIT.java @@ -84,7 +84,7 @@ import java.util.Set; import java.util.stream.IntStream; -import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING; +import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING; import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_REPLICAS; import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS; import static org.opensearch.common.xcontent.XContentFactory.jsonBuilder; @@ -388,7 +388,7 @@ public void testTwoNodeFirstNodeCleared() throws Exception { public Settings onNodeStopped(String nodeName) { return Settings.builder() .put(RECOVER_AFTER_NODES_SETTING.getKey(), 2) - .putList(INITIAL_MASTER_NODES_SETTING.getKey()) // disable bootstrapping + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey()) // disable bootstrapping .build(); } diff --git a/server/src/main/java/org/opensearch/bootstrap/BootstrapChecks.java b/server/src/main/java/org/opensearch/bootstrap/BootstrapChecks.java index e2072cae84733..681df8e45573b 100644 --- a/server/src/main/java/org/opensearch/bootstrap/BootstrapChecks.java +++ b/server/src/main/java/org/opensearch/bootstrap/BootstrapChecks.java @@ -64,7 +64,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING; +import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING; import static org.opensearch.discovery.DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING; import static org.opensearch.discovery.SettingsBasedSeedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING; @@ -774,7 +774,7 @@ public BootstrapCheckResult check(BootstrapContext context) { String.format( Locale.ROOT, "the default discovery settings are unsuitable for production use; at least one of [%s] must be configured", - Stream.of(DISCOVERY_SEED_HOSTS_SETTING, DISCOVERY_SEED_PROVIDERS_SETTING, INITIAL_MASTER_NODES_SETTING) + Stream.of(DISCOVERY_SEED_HOSTS_SETTING, DISCOVERY_SEED_PROVIDERS_SETTING, INITIAL_CLUSTER_MANAGER_NODES_SETTING) .map(Setting::getKey) .collect(Collectors.joining(", ")) ) diff --git a/server/src/main/java/org/opensearch/cluster/coordination/ClusterBootstrapService.java b/server/src/main/java/org/opensearch/cluster/coordination/ClusterBootstrapService.java index 7f239aff2d5a8..03941e78d22dd 100644 --- a/server/src/main/java/org/opensearch/cluster/coordination/ClusterBootstrapService.java +++ b/server/src/main/java/org/opensearch/cluster/coordination/ClusterBootstrapService.java @@ -75,6 +75,15 @@ public class ClusterBootstrapService { "cluster.initial_master_nodes", emptyList(), Function.identity(), + Property.NodeScope, + Property.Deprecated + ); + // The setting below is going to replace the above. + // To keep backwards compatibility, the old usage is remained, and it's also used as the fallback for the new usage. + public static final Setting> INITIAL_CLUSTER_MANAGER_NODES_SETTING = Setting.listSetting( + "cluster.initial_cluster_manager_nodes", + INITIAL_MASTER_NODES_SETTING, + Function.identity(), Property.NodeScope ); @@ -105,10 +114,10 @@ public ClusterBootstrapService( Consumer votingConfigurationConsumer ) { if (DiscoveryModule.isSingleNodeDiscovery(settings)) { - if (INITIAL_MASTER_NODES_SETTING.exists(settings)) { + if (INITIAL_CLUSTER_MANAGER_NODES_SETTING.exists(settings)) { throw new IllegalArgumentException( "setting [" - + INITIAL_MASTER_NODES_SETTING.getKey() + + INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey() + "] is not allowed when [" + DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey() + "] is set to [" @@ -128,11 +137,11 @@ public ClusterBootstrapService( bootstrapRequirements = Collections.singleton(Node.NODE_NAME_SETTING.get(settings)); unconfiguredBootstrapTimeout = null; } else { - final List initialMasterNodes = INITIAL_MASTER_NODES_SETTING.get(settings); + final List initialMasterNodes = INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(settings); bootstrapRequirements = unmodifiableSet(new LinkedHashSet<>(initialMasterNodes)); if (bootstrapRequirements.size() != initialMasterNodes.size()) { throw new IllegalArgumentException( - "setting [" + INITIAL_MASTER_NODES_SETTING.getKey() + "] contains duplicates: " + initialMasterNodes + "setting [" + INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey() + "] contains duplicates: " + initialMasterNodes ); } unconfiguredBootstrapTimeout = discoveryIsConfigured(settings) ? null : UNCONFIGURED_BOOTSTRAP_TIMEOUT_SETTING.get(settings); @@ -150,7 +159,7 @@ public static boolean discoveryIsConfigured(Settings settings) { LEGACY_DISCOVERY_HOSTS_PROVIDER_SETTING, DISCOVERY_SEED_HOSTS_SETTING, LEGACY_DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING, - INITIAL_MASTER_NODES_SETTING + INITIAL_CLUSTER_MANAGER_NODES_SETTING ).anyMatch(s -> s.exists(settings)); } diff --git a/server/src/main/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelper.java b/server/src/main/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelper.java index 394a33eb3cac3..c36a2983a011a 100644 --- a/server/src/main/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelper.java +++ b/server/src/main/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelper.java @@ -56,7 +56,7 @@ import java.util.stream.Collectors; import java.util.stream.StreamSupport; -import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING; +import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING; import static org.opensearch.monitor.StatusInfo.Status.UNHEALTHY; public class ClusterFormationFailureHelper { @@ -198,13 +198,13 @@ String getDescription() { if (clusterState.getLastAcceptedConfiguration().isEmpty()) { final String bootstrappingDescription; - if (INITIAL_MASTER_NODES_SETTING.get(Settings.EMPTY).equals(INITIAL_MASTER_NODES_SETTING.get(settings))) { - bootstrappingDescription = "[" + INITIAL_MASTER_NODES_SETTING.getKey() + "] is empty on this node"; + if (INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(Settings.EMPTY).equals(INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(settings))) { + bootstrappingDescription = "[" + INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey() + "] is empty on this node"; } else { bootstrappingDescription = String.format( Locale.ROOT, "this node must discover master-eligible nodes %s to bootstrap a cluster", - INITIAL_MASTER_NODES_SETTING.get(settings) + INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(settings) ); } diff --git a/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java b/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java index 308ab13a8a785..247898843296f 100644 --- a/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java +++ b/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java @@ -539,7 +539,8 @@ public void apply(Settings value, Settings current, Settings previous) { LeaderChecker.LEADER_CHECK_RETRY_COUNT_SETTING, Reconfigurator.CLUSTER_AUTO_SHRINK_VOTING_CONFIGURATION, TransportAddVotingConfigExclusionsAction.MAXIMUM_VOTING_CONFIG_EXCLUSIONS_SETTING, - ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING, + ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING, // deprecated + ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING, ClusterBootstrapService.UNCONFIGURED_BOOTSTRAP_TIMEOUT_SETTING, LagDetector.CLUSTER_FOLLOWER_LAG_TIMEOUT_SETTING, HandshakingTransportAddressConnector.PROBE_CONNECT_TIMEOUT_SETTING, diff --git a/server/src/test/java/org/opensearch/bootstrap/BootstrapChecksTests.java b/server/src/test/java/org/opensearch/bootstrap/BootstrapChecksTests.java index 04cc138061539..00f9d4110e64c 100644 --- a/server/src/test/java/org/opensearch/bootstrap/BootstrapChecksTests.java +++ b/server/src/test/java/org/opensearch/bootstrap/BootstrapChecksTests.java @@ -815,7 +815,7 @@ public void testDiscoveryConfiguredCheck() throws NodeValidationException { BootstrapChecks.check(context, true, checks); }; - ensureChecksPass.accept(Settings.builder().putList(ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.getKey())); + ensureChecksPass.accept(Settings.builder().putList(ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey())); ensureChecksPass.accept(Settings.builder().putList(DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING.getKey())); ensureChecksPass.accept(Settings.builder().putList(SettingsBasedSeedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING.getKey())); } diff --git a/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceRenamedSettingTests.java b/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceRenamedSettingTests.java new file mode 100644 index 0000000000000..1e1b851f045a7 --- /dev/null +++ b/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceRenamedSettingTests.java @@ -0,0 +1,84 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.cluster.coordination; + +import org.opensearch.common.settings.ClusterSettings; +import org.opensearch.common.settings.Setting; +import org.opensearch.common.settings.Settings; +import org.opensearch.test.OpenSearchTestCase; + +import java.util.Arrays; +import java.util.Set; + +/** + * A unit test to validate the former name of the setting 'cluster.initial_cluster_manager_nodes' still take effect, + * after it is deprecated, so that the backwards compatibility is maintained. + * The test can be removed along with removing support of the deprecated setting. + */ +public class ClusterBootstrapServiceRenamedSettingTests extends OpenSearchTestCase { + /** + * Validate the both settings are known and supported. + */ + public void testReindexSettingsExist() { + Set> settings = ClusterSettings.BUILT_IN_CLUSTER_SETTINGS; + assertTrue( + "Both 'cluster.initial_cluster_manager_nodes' and its predecessor should be supported built-in settings.", + settings.containsAll( + Arrays.asList( + ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING, + ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING + ) + ) + ); + } + + /** + * Validate the default value of the both settings is the same. + */ + public void testSettingFallback() { + assertEquals( + ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(Settings.EMPTY), + ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.get(Settings.EMPTY) + ); + } + + /** + * Validate the new setting can be configured correctly, and it doesn't impact the old setting. + */ + public void testSettingGetValue() { + Settings settings = Settings.builder().put("cluster.initial_cluster_manager_nodes", "node-a").build(); + assertEquals(ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(settings), Arrays.asList("node-a")); + assertEquals( + ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.get(settings), + ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.getDefault(Settings.EMPTY) + ); + } + + /** + * Validate the value of the old setting will be applied to the new setting, if the new setting is not configured. + */ + public void testSettingGetValueWithFallback() { + Settings settings = Settings.builder().put("cluster.initial_master_nodes", "node-a").build(); + assertEquals(ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(settings), Arrays.asList("node-a")); + assertSettingDeprecationsAndWarnings(new Setting[] { ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING }); + } + + /** + * Validate the value of the old setting will be ignored, if the new setting is configured. + */ + public void testSettingGetValueWhenBothAreConfigured() { + Settings settings = Settings.builder() + .put("cluster.initial_cluster_manager_nodes", "node-a") + .put("cluster.initial_master_nodes", "node-a, node-b") + .build(); + assertEquals(ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(settings), Arrays.asList("node-a")); + assertEquals(ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.get(settings), Arrays.asList("node-a", "node-b")); + assertSettingDeprecationsAndWarnings(new Setting[] { ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING }); + } +} diff --git a/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceTests.java b/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceTests.java index a2fe39ef4531e..a5261c810dc9f 100644 --- a/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceTests.java @@ -57,7 +57,7 @@ import static java.util.Collections.emptySet; import static java.util.Collections.singletonList; import static org.opensearch.cluster.coordination.ClusterBootstrapService.BOOTSTRAP_PLACEHOLDER_PREFIX; -import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING; +import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING; import static org.opensearch.cluster.coordination.ClusterBootstrapService.UNCONFIGURED_BOOTSTRAP_TIMEOUT_SETTING; import static org.opensearch.common.settings.Settings.builder; import static org.opensearch.discovery.DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING; @@ -166,7 +166,7 @@ public void testDoesNothingByDefaultIfSeedHostsConfigured() { } public void testDoesNothingByDefaultIfMasterNodesConfigured() { - testDoesNothingWithSettings(builder().putList(INITIAL_MASTER_NODES_SETTING.getKey())); + testDoesNothingWithSettings(builder().putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey())); } public void testDoesNothingByDefaultOnMasterIneligibleNodes() { @@ -197,7 +197,7 @@ private void testDoesNothingWithSettings(Settings.Builder builder) { public void testThrowsExceptionOnDuplicates() { final IllegalArgumentException illegalArgumentException = expectThrows(IllegalArgumentException.class, () -> { new ClusterBootstrapService( - builder().putList(INITIAL_MASTER_NODES_SETTING.getKey(), "duplicate-requirement", "duplicate-requirement").build(), + builder().putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), "duplicate-requirement", "duplicate-requirement").build(), transportService, Collections::emptyList, () -> false, @@ -205,7 +205,7 @@ public void testThrowsExceptionOnDuplicates() { ); }); - assertThat(illegalArgumentException.getMessage(), containsString(INITIAL_MASTER_NODES_SETTING.getKey())); + assertThat(illegalArgumentException.getMessage(), containsString(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey())); assertThat(illegalArgumentException.getMessage(), containsString("duplicate-requirement")); } @@ -214,7 +214,7 @@ public void testBootstrapsOnDiscoveryOfAllRequiredNodes() { ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( Settings.builder() - .putList(INITIAL_MASTER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) .build(), transportService, () -> Stream.of(otherNode1, otherNode2).collect(Collectors.toList()), @@ -242,7 +242,7 @@ public void testBootstrapsOnDiscoveryOfTwoOfThreeRequiredNodes() { ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( Settings.builder() - .putList(INITIAL_MASTER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) .build(), transportService, () -> singletonList(otherNode1), @@ -276,7 +276,7 @@ public void testBootstrapsOnDiscoveryOfThreeOfFiveRequiredNodes() { ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( Settings.builder() .putList( - INITIAL_MASTER_NODES_SETTING.getKey(), + INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName(), @@ -325,7 +325,7 @@ public void testBootstrapsOnDiscoveryOfThreeOfFiveRequiredNodes() { public void testDoesNotBootstrapIfNoNodesDiscovered() { ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( Settings.builder() - .putList(INITIAL_MASTER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) .build(), transportService, Collections::emptyList, @@ -342,7 +342,7 @@ public void testDoesNotBootstrapIfTwoOfFiveNodesDiscovered() { ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( Settings.builder() .putList( - INITIAL_MASTER_NODES_SETTING.getKey(), + INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName(), @@ -365,7 +365,7 @@ public void testDoesNotBootstrapIfThreeOfSixNodesDiscovered() { ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( Settings.builder() .putList( - INITIAL_MASTER_NODES_SETTING.getKey(), + INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName(), @@ -388,7 +388,7 @@ public void testDoesNotBootstrapIfThreeOfSixNodesDiscovered() { public void testDoesNotBootstrapIfAlreadyBootstrapped() { ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( Settings.builder() - .putList(INITIAL_MASTER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) .build(), transportService, () -> Stream.of(otherNode1, otherNode2).collect(Collectors.toList()), @@ -412,7 +412,7 @@ public void testDoesNotBootstrapsOnNonMasterNode() { ); ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( Settings.builder() - .putList(INITIAL_MASTER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) .build(), transportService, () -> Stream.of(localNode, otherNode1, otherNode2).collect(Collectors.toList()), @@ -426,7 +426,7 @@ public void testDoesNotBootstrapsOnNonMasterNode() { public void testDoesNotBootstrapsIfLocalNodeNotInInitialMasterNodes() { ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( - Settings.builder().putList(INITIAL_MASTER_NODES_SETTING.getKey(), otherNode1.getName(), otherNode2.getName()).build(), + Settings.builder().putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), otherNode1.getName(), otherNode2.getName()).build(), transportService, () -> Stream.of(localNode, otherNode1, otherNode2).collect(Collectors.toList()), () -> false, @@ -439,7 +439,7 @@ public void testDoesNotBootstrapsIfLocalNodeNotInInitialMasterNodes() { public void testDoesNotBootstrapsIfNotConfigured() { ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( - Settings.builder().putList(INITIAL_MASTER_NODES_SETTING.getKey()).build(), + Settings.builder().putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey()).build(), transportService, () -> Stream.of(localNode, otherNode1, otherNode2).collect(Collectors.toList()), () -> false, @@ -455,7 +455,7 @@ public void testRetriesBootstrappingOnException() { final AtomicLong bootstrappingAttempts = new AtomicLong(); ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( Settings.builder() - .putList(INITIAL_MASTER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) .build(), transportService, () -> Stream.of(otherNode1, otherNode2).collect(Collectors.toList()), @@ -480,7 +480,7 @@ public void testCancelsBootstrapIfRequirementMatchesMultipleNodes() { Stream.of(otherNode1, otherNode2).collect(Collectors.toList()) ); ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( - Settings.builder().putList(INITIAL_MASTER_NODES_SETTING.getKey(), localNode.getAddress().getAddress()).build(), + Settings.builder().putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getAddress().getAddress()).build(), transportService, discoveredNodes::get, () -> false, @@ -502,7 +502,7 @@ public void testCancelsBootstrapIfNodeMatchesMultipleRequirements() { ); ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( Settings.builder() - .putList(INITIAL_MASTER_NODES_SETTING.getKey(), otherNode1.getAddress().toString(), otherNode1.getName()) + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), otherNode1.getAddress().toString(), otherNode1.getName()) .build(), transportService, discoveredNodes::get, @@ -542,7 +542,7 @@ public void testCancelsBootstrapIfNodeMatchesMultipleRequirements() { public void testMatchesOnNodeName() { final AtomicBoolean bootstrapped = new AtomicBoolean(); ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( - Settings.builder().putList(INITIAL_MASTER_NODES_SETTING.getKey(), localNode.getName()).build(), + Settings.builder().putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getName()).build(), transportService, Collections::emptyList, () -> false, @@ -558,7 +558,7 @@ public void testMatchesOnNodeName() { public void testMatchesOnNodeAddress() { final AtomicBoolean bootstrapped = new AtomicBoolean(); ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( - Settings.builder().putList(INITIAL_MASTER_NODES_SETTING.getKey(), localNode.getAddress().toString()).build(), + Settings.builder().putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getAddress().toString()).build(), transportService, Collections::emptyList, () -> false, @@ -574,7 +574,7 @@ public void testMatchesOnNodeAddress() { public void testMatchesOnNodeHostAddress() { final AtomicBoolean bootstrapped = new AtomicBoolean(); ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( - Settings.builder().putList(INITIAL_MASTER_NODES_SETTING.getKey(), localNode.getAddress().getAddress()).build(), + Settings.builder().putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getAddress().getAddress()).build(), transportService, Collections::emptyList, () -> false, @@ -589,7 +589,7 @@ public void testMatchesOnNodeHostAddress() { public void testDoesNotJustMatchEverything() { ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( - Settings.builder().putList(INITIAL_MASTER_NODES_SETTING.getKey(), randomAlphaOfLength(10)).build(), + Settings.builder().putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), randomAlphaOfLength(10)).build(), transportService, Collections::emptyList, () -> false, @@ -606,7 +606,7 @@ public void testDoesNotIncludeExtraNodes() { final AtomicBoolean bootstrapped = new AtomicBoolean(); ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( Settings.builder() - .putList(INITIAL_MASTER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) .build(), transportService, () -> Stream.of(otherNode1, otherNode2, extraNode).collect(Collectors.toList()), @@ -657,7 +657,7 @@ public void testFailBootstrapWithBothSingleNodeDiscoveryAndInitialMasterNodes() final Settings.Builder settings = Settings.builder() .put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), DiscoveryModule.SINGLE_NODE_DISCOVERY_TYPE) .put(NODE_NAME_SETTING.getKey(), localNode.getName()) - .put(INITIAL_MASTER_NODES_SETTING.getKey(), "test"); + .put(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), "test"); assertThat( expectThrows( @@ -665,7 +665,10 @@ public void testFailBootstrapWithBothSingleNodeDiscoveryAndInitialMasterNodes() () -> new ClusterBootstrapService(settings.build(), transportService, () -> emptyList(), () -> false, vc -> fail()) ).getMessage(), containsString( - "setting [" + INITIAL_MASTER_NODES_SETTING.getKey() + "] is not allowed when [discovery.type] is set " + "to [single-node]" + "setting [" + + INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey() + + "] is not allowed when [discovery.type] is set " + + "to [single-node]" ) ); } diff --git a/server/src/test/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelperTests.java b/server/src/test/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelperTests.java index c53c6fb8f4a18..f59124d319b3a 100644 --- a/server/src/test/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelperTests.java +++ b/server/src/test/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelperTests.java @@ -56,7 +56,7 @@ import static java.util.Collections.emptySet; import static java.util.Collections.singletonList; import static org.opensearch.cluster.coordination.ClusterBootstrapService.BOOTSTRAP_PLACEHOLDER_PREFIX; -import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING; +import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING; import static org.opensearch.monitor.StatusInfo.Status.HEALTHY; import static org.opensearch.monitor.StatusInfo.Status.UNHEALTHY; import static org.opensearch.node.Node.NODE_NAME_SETTING; @@ -382,7 +382,7 @@ public void testDescriptionBeforeBootstrapping() { assertThat( new ClusterFormationState( - Settings.builder().putList(INITIAL_MASTER_NODES_SETTING.getKey(), "other").build(), + Settings.builder().putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), "other").build(), clusterState, emptyList(), emptyList(), diff --git a/server/src/test/java/org/opensearch/indices/IndicesServiceCloseTests.java b/server/src/test/java/org/opensearch/indices/IndicesServiceCloseTests.java index ff97b87708202..e3b2afaccf054 100644 --- a/server/src/test/java/org/opensearch/indices/IndicesServiceCloseTests.java +++ b/server/src/test/java/org/opensearch/indices/IndicesServiceCloseTests.java @@ -64,7 +64,7 @@ import java.util.Collections; import java.util.concurrent.TimeUnit; -import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING; +import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING; import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_REPLICAS; import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS; import static org.opensearch.discovery.SettingsBasedSeedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING; @@ -94,7 +94,7 @@ private Node startNode() throws NodeValidationException { // turn it off for these tests. .put(HierarchyCircuitBreakerService.USE_REAL_MEMORY_USAGE_SETTING.getKey(), false) .putList(DISCOVERY_SEED_HOSTS_SETTING.getKey()) // empty list disables a port scan for other nodes - .putList(INITIAL_MASTER_NODES_SETTING.getKey(), nodeName) + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), nodeName) .put(IndicesQueryCache.INDICES_QUERIES_CACHE_ALL_SEGMENTS_SETTING.getKey(), true) .build(); diff --git a/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java b/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java index 74da44af28e1d..5e7def04fe8c8 100644 --- a/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java +++ b/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java @@ -1445,8 +1445,8 @@ private Environment createEnvironment(String nodeName) { .put(PATH_HOME_SETTING.getKey(), tempDir.resolve(nodeName).toAbsolutePath()) .put(Environment.PATH_REPO_SETTING.getKey(), tempDir.resolve("repo").toAbsolutePath()) .putList( - ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.getKey(), - ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.get(Settings.EMPTY) + ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), + ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(Settings.EMPTY) ) .put(MappingUpdatedAction.INDICES_MAX_IN_FLIGHT_UPDATES_SETTING.getKey(), 1000) // o.w. some tests might block .build() diff --git a/test/framework/src/main/java/org/opensearch/cluster/coordination/AbstractCoordinatorTestCase.java b/test/framework/src/main/java/org/opensearch/cluster/coordination/AbstractCoordinatorTestCase.java index 828496ebfa3a4..9841daa5f81b7 100644 --- a/test/framework/src/main/java/org/opensearch/cluster/coordination/AbstractCoordinatorTestCase.java +++ b/test/framework/src/main/java/org/opensearch/cluster/coordination/AbstractCoordinatorTestCase.java @@ -1089,8 +1089,8 @@ protected Optional getDisruptableMockTransport(Transpo : Settings.builder() .put(nodeSettings) .putList( - ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.getKey(), - ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.get(Settings.EMPTY) + ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), + ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(Settings.EMPTY) ) .build(); // suppress auto-bootstrap transportService = mockTransport.createTransportService( diff --git a/test/framework/src/main/java/org/opensearch/test/InternalTestCluster.java b/test/framework/src/main/java/org/opensearch/test/InternalTestCluster.java index 5ae441ed651b1..f60c6e75b92e8 100644 --- a/test/framework/src/main/java/org/opensearch/test/InternalTestCluster.java +++ b/test/framework/src/main/java/org/opensearch/test/InternalTestCluster.java @@ -157,7 +157,7 @@ import static org.apache.lucene.util.LuceneTestCase.TEST_NIGHTLY; import static org.apache.lucene.util.LuceneTestCase.rarely; -import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING; +import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING; import static org.opensearch.common.unit.TimeValue.timeValueMillis; import static org.opensearch.common.unit.TimeValue.timeValueSeconds; import static org.opensearch.discovery.DiscoveryModule.DISCOVERY_TYPE_SETTING; @@ -616,7 +616,7 @@ private NodeAndClient getOrBuildRandomNode() { final int nodeId = nextNodeId.getAndIncrement(); final Settings settings = getNodeSettings(nodeId, random.nextLong(), Settings.EMPTY, 1); final Settings nodeSettings = Settings.builder() - .putList(INITIAL_MASTER_NODES_SETTING.getKey(), Node.NODE_NAME_SETTING.get(settings)) + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), Node.NODE_NAME_SETTING.get(settings)) .put(settings) .build(); final NodeAndClient buildNode = buildNode(nodeId, nodeSettings, false, onTransportServiceStarted); @@ -990,8 +990,8 @@ Settings closeForRestart(RestartCallback callback, int minMasterNodes) throws Ex Settings.Builder newSettings = Settings.builder(); newSettings.put(callbackSettings); if (minMasterNodes >= 0) { - if (INITIAL_MASTER_NODES_SETTING.exists(callbackSettings) == false) { - newSettings.putList(INITIAL_MASTER_NODES_SETTING.getKey()); + if (INITIAL_CLUSTER_MANAGER_NODES_SETTING.exists(callbackSettings) == false) { + newSettings.putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey()); } } // delete data folders now, before we start other nodes that may claim it @@ -1174,7 +1174,10 @@ private synchronized void reset(boolean wipeData) throws IOException { for (int i = 0; i < numSharedDedicatedMasterNodes + numSharedDataNodes + numSharedCoordOnlyNodes; i++) { Settings nodeSettings = updatedSettings.get(i); if (i == autoBootstrapMasterNodeIndex) { - nodeSettings = Settings.builder().putList(INITIAL_MASTER_NODES_SETTING.getKey(), masterNodeNames).put(nodeSettings).build(); + nodeSettings = Settings.builder() + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), masterNodeNames) + .put(nodeSettings) + .build(); } final NodeAndClient nodeAndClient = buildNode(i, nodeSettings, true, onTransportServiceStarted); toStartAndPublish.add(nodeAndClient); @@ -2034,7 +2037,7 @@ private List bootstrapMasterNodeWithSpecifiedIndex(List allN newSettings.add( Settings.builder() .put(settings) - .putList(ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.getKey(), nodeNames) + .putList(ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), nodeNames) .build() ); @@ -2122,7 +2125,7 @@ public synchronized List startNodes(Settings... extraSettings) { final Builder builder = Settings.builder(); if (DiscoveryNode.isMasterNode(nodeSettings)) { if (autoBootstrapMasterNodeIndex == 0) { - builder.putList(INITIAL_MASTER_NODES_SETTING.getKey(), initialMasterNodes); + builder.putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), initialMasterNodes); } autoBootstrapMasterNodeIndex -= 1; } diff --git a/test/framework/src/main/java/org/opensearch/test/OpenSearchSingleNodeTestCase.java b/test/framework/src/main/java/org/opensearch/test/OpenSearchSingleNodeTestCase.java index 83e59e1edd8c8..e123f3ba2fe6f 100644 --- a/test/framework/src/main/java/org/opensearch/test/OpenSearchSingleNodeTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/OpenSearchSingleNodeTestCase.java @@ -78,7 +78,7 @@ import java.util.Collections; import java.util.concurrent.TimeUnit; -import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING; +import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING; import static org.opensearch.discovery.SettingsBasedSeedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING; import static org.opensearch.test.NodeRoles.dataNode; import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked; @@ -241,7 +241,7 @@ private Node newNode() { // turn it off for these tests. .put(HierarchyCircuitBreakerService.USE_REAL_MEMORY_USAGE_SETTING.getKey(), false) .putList(DISCOVERY_SEED_HOSTS_SETTING.getKey()) // empty list disables a port scan for other nodes - .putList(INITIAL_MASTER_NODES_SETTING.getKey(), nodeName) + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), nodeName) .put(nodeSettings()) // allow test cases to provide their own settings or override these .build(); From 11646a40b080441f5052f8255ed9cb7f3f62a39c Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Mon, 14 Mar 2022 13:31:53 -0700 Subject: [PATCH 02/13] Rename cluster.initial_master_nodes to cluster.initial_cluster_manager_nodes Signed-off-by: Tianli Feng --- .../org/opensearch/gradle/test/ClusterFormationTasks.groovy | 2 +- .../opensearch/gradle/testclusters/OpenSearchCluster.java | 2 +- distribution/docker/docker-compose.yml | 4 ++-- distribution/src/config/opensearch.yml | 2 +- qa/remote-clusters/docker-compose.yml | 4 ++-- .../java/org/opensearch/bootstrap/BootstrapChecksTests.java | 2 +- .../coordination/ClusterFormationFailureHelperTests.java | 6 +++--- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/buildSrc/src/main/groovy/org/opensearch/gradle/test/ClusterFormationTasks.groovy b/buildSrc/src/main/groovy/org/opensearch/gradle/test/ClusterFormationTasks.groovy index c3dd2526de385..a81abb1bc4618 100644 --- a/buildSrc/src/main/groovy/org/opensearch/gradle/test/ClusterFormationTasks.groovy +++ b/buildSrc/src/main/groovy/org/opensearch/gradle/test/ClusterFormationTasks.groovy @@ -153,7 +153,7 @@ class ClusterFormationTasks { } boolean supportsInitialMasterNodes = hasBwcNodes == false || config.bwcVersion.onOrAfter("7.0.0") if (esConfig['discovery.type'] == null && config.getAutoSetInitialMasterNodes() && supportsInitialMasterNodes) { - esConfig['cluster.initial_master_nodes'] = nodes.stream().map({ n -> + esConfig['cluster.initial_cluster_manager_nodes'] = nodes.stream().map({ n -> if (n.config.settings['node.name'] == null) { return "node-" + n.nodeNum } else { diff --git a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java b/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java index a94ebacd460a5..25104d4d53b8c 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java @@ -361,7 +361,7 @@ private void commonNodeConfig(OpenSearchNode node, String nodeNames, OpenSearchN .collect(Collectors.toList()) .forEach(node.defaultConfig::remove); if (nodeNames != null && node.settings.getOrDefault("discovery.type", "anything").equals("single-node") == false) { - node.defaultConfig.put("cluster.initial_master_nodes", "[" + nodeNames + "]"); + node.defaultConfig.put("cluster.initial_cluster_manager_nodes", "[" + nodeNames + "]"); } node.defaultConfig.put("discovery.seed_providers", "file"); node.defaultConfig.put("discovery.seed_hosts", "[]"); diff --git a/distribution/docker/docker-compose.yml b/distribution/docker/docker-compose.yml index f648a514e1db4..e063500420cd2 100644 --- a/distribution/docker/docker-compose.yml +++ b/distribution/docker/docker-compose.yml @@ -5,7 +5,7 @@ services: image: opensearch:test environment: - node.name=opensearch-1 - - cluster.initial_master_nodes=opensearch-1,opensearch-2 + - cluster.initial_cluster_manager_nodes=opensearch-1,opensearch-2 - discovery.seed_hosts=opensearch-2:9300 - cluster.name=opensearch - bootstrap.memory_lock=true @@ -29,7 +29,7 @@ services: image: opensearch:test environment: - node.name=opensearch-2 - - cluster.initial_master_nodes=opensearch-1,opensearch-2 + - cluster.initial_cluster_manager_nodes_nodes=opensearch-1,opensearch-2 - discovery.seed_hosts=opensearch-1:9300 - cluster.name=opensearch - bootstrap.memory_lock=true diff --git a/distribution/src/config/opensearch.yml b/distribution/src/config/opensearch.yml index accc920e6aa17..155030b672eb1 100644 --- a/distribution/src/config/opensearch.yml +++ b/distribution/src/config/opensearch.yml @@ -69,7 +69,7 @@ ${path.logs} # # Bootstrap the cluster using an initial set of master-eligible nodes: # -#cluster.initial_master_nodes: ["node-1", "node-2"] +#cluster.initial_cluster_manager_nodes: ["node-1", "node-2"] # # For more information, consult the discovery and cluster formation module documentation. # diff --git a/qa/remote-clusters/docker-compose.yml b/qa/remote-clusters/docker-compose.yml index 74aaa9e2a5271..cf6aefcf5c1a3 100644 --- a/qa/remote-clusters/docker-compose.yml +++ b/qa/remote-clusters/docker-compose.yml @@ -5,7 +5,7 @@ services: image: opensearch:test environment: - node.name=opensearch-1 - - cluster.initial_master_nodes=opensearch-1 + - cluster.initial_cluster_manager_nodes=opensearch-1 - cluster.name=opensearch-1 - bootstrap.memory_lock=true - network.publish_host=127.0.0.1 @@ -39,7 +39,7 @@ services: image: opensearch:test environment: - node.name=opensearch-2 - - cluster.initial_master_nodes=opensearch-2 + - cluster.initial_cluster_manager_nodes=opensearch-2 - cluster.name=opensearch-2 - bootstrap.memory_lock=true - network.publish_host=127.0.0.1 diff --git a/server/src/test/java/org/opensearch/bootstrap/BootstrapChecksTests.java b/server/src/test/java/org/opensearch/bootstrap/BootstrapChecksTests.java index 00f9d4110e64c..00b771eeac62d 100644 --- a/server/src/test/java/org/opensearch/bootstrap/BootstrapChecksTests.java +++ b/server/src/test/java/org/opensearch/bootstrap/BootstrapChecksTests.java @@ -802,7 +802,7 @@ public void testDiscoveryConfiguredCheck() throws NodeValidationException { hasToString( containsString( "the default discovery settings are unsuitable for production use; at least one " - + "of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured" + + "of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_cluster_manager_nodes] must be configured" ) ) ); diff --git a/server/src/test/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelperTests.java b/server/src/test/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelperTests.java index f59124d319b3a..4288d4eb5d53b 100644 --- a/server/src/test/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelperTests.java +++ b/server/src/test/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelperTests.java @@ -329,7 +329,7 @@ public void testDescriptionBeforeBootstrapping() { ).getDescription(), is( "master not discovered yet, this node has not previously joined a bootstrapped cluster, and " - + "[cluster.initial_master_nodes] is empty on this node: have discovered []; " + + "[cluster.initial_cluster_manager_nodes] is empty on this node: have discovered []; " + "discovery will continue using [] from hosts providers and [" + localNode + "] from last-known cluster state; node term 1, last-accepted version 7 in term 4" @@ -349,7 +349,7 @@ public void testDescriptionBeforeBootstrapping() { ).getDescription(), is( "master not discovered yet, this node has not previously joined a bootstrapped cluster, and " - + "[cluster.initial_master_nodes] is empty on this node: have discovered []; " + + "[cluster.initial_cluster_manager_nodes] is empty on this node: have discovered []; " + "discovery will continue using [" + otherAddress + "] from hosts providers and [" @@ -371,7 +371,7 @@ public void testDescriptionBeforeBootstrapping() { ).getDescription(), is( "master not discovered yet, this node has not previously joined a bootstrapped cluster, and " - + "[cluster.initial_master_nodes] is empty on this node: have discovered [" + + "[cluster.initial_cluster_manager_nodes] is empty on this node: have discovered [" + otherNode + "]; " + "discovery will continue using [] from hosts providers and [" From 1fa949c51784f04ea19b15ffa41efe6cffb3254b Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Mon, 14 Mar 2022 13:34:14 -0700 Subject: [PATCH 03/13] Replace master-eligible to cluster-manager-eligible in opensearch.yml Signed-off-by: Tianli Feng --- distribution/src/config/opensearch.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distribution/src/config/opensearch.yml b/distribution/src/config/opensearch.yml index 155030b672eb1..2188fbe600cbf 100644 --- a/distribution/src/config/opensearch.yml +++ b/distribution/src/config/opensearch.yml @@ -67,7 +67,7 @@ ${path.logs} # #discovery.seed_hosts: ["host1", "host2"] # -# Bootstrap the cluster using an initial set of master-eligible nodes: +# Bootstrap the cluster using an initial set of cluster-manager-eligible nodes: # #cluster.initial_cluster_manager_nodes: ["node-1", "node-2"] # From 04ced0dbe88b2a462a3697ada7b9aa89965b94ac Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Mon, 14 Mar 2022 21:12:39 +0000 Subject: [PATCH 04/13] Fix bwc test by configuring setting name Signed-off-by: Tianli Feng --- .../opensearch/gradle/test/ClusterFormationTasks.groovy | 3 ++- .../opensearch/gradle/testclusters/OpenSearchCluster.java | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/buildSrc/src/main/groovy/org/opensearch/gradle/test/ClusterFormationTasks.groovy b/buildSrc/src/main/groovy/org/opensearch/gradle/test/ClusterFormationTasks.groovy index a81abb1bc4618..0c88c33921309 100644 --- a/buildSrc/src/main/groovy/org/opensearch/gradle/test/ClusterFormationTasks.groovy +++ b/buildSrc/src/main/groovy/org/opensearch/gradle/test/ClusterFormationTasks.groovy @@ -153,7 +153,8 @@ class ClusterFormationTasks { } boolean supportsInitialMasterNodes = hasBwcNodes == false || config.bwcVersion.onOrAfter("7.0.0") if (esConfig['discovery.type'] == null && config.getAutoSetInitialMasterNodes() && supportsInitialMasterNodes) { - esConfig['cluster.initial_cluster_manager_nodes'] = nodes.stream().map({ n -> + // To promote inclusive language, the old setting name is deprecated in 2.0.0 + esConfig[node.nodeVersion.onOrAfter("2.0.0") ? 'cluster.initial_cluster_manager_nodes' : 'cluster.initial_master_nodes'] = nodes.stream().map({ n -> if (n.config.settings['node.name'] == null) { return "node-" + n.nodeNum } else { diff --git a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java b/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java index 25104d4d53b8c..ef52adab6377a 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java @@ -361,7 +361,12 @@ private void commonNodeConfig(OpenSearchNode node, String nodeNames, OpenSearchN .collect(Collectors.toList()) .forEach(node.defaultConfig::remove); if (nodeNames != null && node.settings.getOrDefault("discovery.type", "anything").equals("single-node") == false) { - node.defaultConfig.put("cluster.initial_cluster_manager_nodes", "[" + nodeNames + "]"); + // To promote inclusive language, the old setting name is deprecated n 2.0.0 + if (node.getVersion().onOrAfter("2.0.0")) { + node.defaultConfig.put("cluster.initial_cluster_manager_nodes", "[" + nodeNames + "]"); + } else { + node.defaultConfig.put("cluster.initial_master_nodes", "[" + nodeNames + "]"); + } } node.defaultConfig.put("discovery.seed_providers", "file"); node.defaultConfig.put("discovery.seed_hosts", "[]"); From cf2287424e419cbf9514cad51b3f6cb412d92e2f Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Mon, 14 Mar 2022 21:51:37 +0000 Subject: [PATCH 05/13] Correct a setting name in docker-compose Signed-off-by: Tianli Feng --- distribution/docker/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distribution/docker/docker-compose.yml b/distribution/docker/docker-compose.yml index e063500420cd2..5ed2b159ffe2b 100644 --- a/distribution/docker/docker-compose.yml +++ b/distribution/docker/docker-compose.yml @@ -29,7 +29,7 @@ services: image: opensearch:test environment: - node.name=opensearch-2 - - cluster.initial_cluster_manager_nodes_nodes=opensearch-1,opensearch-2 + - cluster.initial_cluster_manager_nodes=opensearch-1,opensearch-2 - discovery.seed_hosts=opensearch-1:9300 - cluster.name=opensearch - bootstrap.memory_lock=true From e00348ef943d8953457f1db9600920bcc0e78e16 Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Tue, 15 Mar 2022 20:17:01 -0700 Subject: [PATCH 06/13] Revert changing an error message in bootstrapchecks Signed-off-by: Tianli Feng --- .../main/java/org/opensearch/bootstrap/BootstrapChecks.java | 3 ++- .../java/org/opensearch/bootstrap/BootstrapChecksTests.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/opensearch/bootstrap/BootstrapChecks.java b/server/src/main/java/org/opensearch/bootstrap/BootstrapChecks.java index 681df8e45573b..5b8b9a404b829 100644 --- a/server/src/main/java/org/opensearch/bootstrap/BootstrapChecks.java +++ b/server/src/main/java/org/opensearch/bootstrap/BootstrapChecks.java @@ -65,6 +65,7 @@ import java.util.stream.Stream; import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING; +import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING; import static org.opensearch.discovery.DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING; import static org.opensearch.discovery.SettingsBasedSeedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING; @@ -774,7 +775,7 @@ public BootstrapCheckResult check(BootstrapContext context) { String.format( Locale.ROOT, "the default discovery settings are unsuitable for production use; at least one of [%s] must be configured", - Stream.of(DISCOVERY_SEED_HOSTS_SETTING, DISCOVERY_SEED_PROVIDERS_SETTING, INITIAL_CLUSTER_MANAGER_NODES_SETTING) + Stream.of(DISCOVERY_SEED_HOSTS_SETTING, DISCOVERY_SEED_PROVIDERS_SETTING, INITIAL_MASTER_NODES_SETTING) .map(Setting::getKey) .collect(Collectors.joining(", ")) ) diff --git a/server/src/test/java/org/opensearch/bootstrap/BootstrapChecksTests.java b/server/src/test/java/org/opensearch/bootstrap/BootstrapChecksTests.java index 00b771eeac62d..00f9d4110e64c 100644 --- a/server/src/test/java/org/opensearch/bootstrap/BootstrapChecksTests.java +++ b/server/src/test/java/org/opensearch/bootstrap/BootstrapChecksTests.java @@ -802,7 +802,7 @@ public void testDiscoveryConfiguredCheck() throws NodeValidationException { hasToString( containsString( "the default discovery settings are unsuitable for production use; at least one " - + "of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_cluster_manager_nodes] must be configured" + + "of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured" ) ) ); From 03e29f8fbde874b4de1c308e1751d6a737bff75e Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Tue, 15 Mar 2022 20:41:00 -0700 Subject: [PATCH 07/13] Show correct setting name in exception message Signed-off-by: Tianli Feng --- .../opensearch/bootstrap/BootstrapChecks.java | 1 - .../coordination/ClusterBootstrapService.java | 8 ++++-- .../ClusterBootstrapServiceTests.java | 28 +++++++++++++++---- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/server/src/main/java/org/opensearch/bootstrap/BootstrapChecks.java b/server/src/main/java/org/opensearch/bootstrap/BootstrapChecks.java index 5b8b9a404b829..e2072cae84733 100644 --- a/server/src/main/java/org/opensearch/bootstrap/BootstrapChecks.java +++ b/server/src/main/java/org/opensearch/bootstrap/BootstrapChecks.java @@ -64,7 +64,6 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING; import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING; import static org.opensearch.discovery.DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING; import static org.opensearch.discovery.SettingsBasedSeedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING; diff --git a/server/src/main/java/org/opensearch/cluster/coordination/ClusterBootstrapService.java b/server/src/main/java/org/opensearch/cluster/coordination/ClusterBootstrapService.java index 03941e78d22dd..dbc5e6dad9619 100644 --- a/server/src/main/java/org/opensearch/cluster/coordination/ClusterBootstrapService.java +++ b/server/src/main/java/org/opensearch/cluster/coordination/ClusterBootstrapService.java @@ -114,10 +114,14 @@ public ClusterBootstrapService( Consumer votingConfigurationConsumer ) { if (DiscoveryModule.isSingleNodeDiscovery(settings)) { - if (INITIAL_CLUSTER_MANAGER_NODES_SETTING.exists(settings)) { + if (INITIAL_MASTER_NODES_SETTING.exists(settings) || INITIAL_CLUSTER_MANAGER_NODES_SETTING.exists(settings)) { + // TODO: Remove variable 'initialClusterManagerSettingName' after removing MASTER_ROLE. + String initialClusterManagerSettingName = INITIAL_CLUSTER_MANAGER_NODES_SETTING.exists(settings) + ? INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey() + : INITIAL_MASTER_NODES_SETTING.getKey(); throw new IllegalArgumentException( "setting [" - + INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey() + + initialClusterManagerSettingName + "] is not allowed when [" + DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey() + "] is set to [" diff --git a/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceTests.java b/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceTests.java index a5261c810dc9f..97b2b0edc00a1 100644 --- a/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceTests.java @@ -56,9 +56,7 @@ import static java.util.Collections.emptyMap; import static java.util.Collections.emptySet; import static java.util.Collections.singletonList; -import static org.opensearch.cluster.coordination.ClusterBootstrapService.BOOTSTRAP_PLACEHOLDER_PREFIX; -import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING; -import static org.opensearch.cluster.coordination.ClusterBootstrapService.UNCONFIGURED_BOOTSTRAP_TIMEOUT_SETTING; +import static org.opensearch.cluster.coordination.ClusterBootstrapService.*; import static org.opensearch.common.settings.Settings.builder; import static org.opensearch.discovery.DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING; import static org.opensearch.discovery.SettingsBasedSeedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING; @@ -654,6 +652,27 @@ public void testBootstrapsAutomaticallyWithSingleNodeDiscovery() { } public void testFailBootstrapWithBothSingleNodeDiscoveryAndInitialMasterNodes() { + final Settings.Builder settings = Settings.builder() + .put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), DiscoveryModule.SINGLE_NODE_DISCOVERY_TYPE) + .put(NODE_NAME_SETTING.getKey(), localNode.getName()) + .put(INITIAL_MASTER_NODES_SETTING.getKey(), "test"); + + assertThat( + expectThrows( + IllegalArgumentException.class, + () -> new ClusterBootstrapService(settings.build(), transportService, () -> emptyList(), () -> false, vc -> fail()) + ).getMessage(), + containsString( + "setting [" + INITIAL_MASTER_NODES_SETTING.getKey() + "] is not allowed when [discovery.type] is set " + "to [single-node]" + ) + ); + } + + /** + * Validate the correct setting name of cluster.initial_cluster_manager_nodes is shown in the exception, + * when discovery type is single-node. + */ + public void testFailBootstrapWithBothSingleNodeDiscoveryAndInitialClusterManagerNodes() { final Settings.Builder settings = Settings.builder() .put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), DiscoveryModule.SINGLE_NODE_DISCOVERY_TYPE) .put(NODE_NAME_SETTING.getKey(), localNode.getName()) @@ -667,8 +686,7 @@ public void testFailBootstrapWithBothSingleNodeDiscoveryAndInitialMasterNodes() containsString( "setting [" + INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey() - + "] is not allowed when [discovery.type] is set " - + "to [single-node]" + + "] is not allowed when [discovery.type] is set to [single-node]" ) ); } From 82ec6a0e4dab08708fad253241b6dc893288fb1a Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Tue, 15 Mar 2022 20:44:21 -0700 Subject: [PATCH 08/13] Flip arguments in assertEquals(), because the first is expected value Signed-off-by: Tianli Feng --- ...usterBootstrapServiceRenamedSettingTests.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceRenamedSettingTests.java b/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceRenamedSettingTests.java index 1e1b851f045a7..09fb6a5ea256d 100644 --- a/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceRenamedSettingTests.java +++ b/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceRenamedSettingTests.java @@ -43,8 +43,8 @@ public void testReindexSettingsExist() { */ public void testSettingFallback() { assertEquals( - ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(Settings.EMPTY), - ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.get(Settings.EMPTY) + ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.get(Settings.EMPTY), + ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(Settings.EMPTY) ); } @@ -53,10 +53,10 @@ public void testSettingFallback() { */ public void testSettingGetValue() { Settings settings = Settings.builder().put("cluster.initial_cluster_manager_nodes", "node-a").build(); - assertEquals(ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(settings), Arrays.asList("node-a")); + assertEquals(Arrays.asList("node-a"), ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(settings)); assertEquals( - ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.get(settings), - ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.getDefault(Settings.EMPTY) + ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.getDefault(Settings.EMPTY), + ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.get(settings) ); } @@ -65,7 +65,7 @@ public void testSettingGetValue() { */ public void testSettingGetValueWithFallback() { Settings settings = Settings.builder().put("cluster.initial_master_nodes", "node-a").build(); - assertEquals(ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(settings), Arrays.asList("node-a")); + assertEquals(Arrays.asList("node-a"), ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(settings)); assertSettingDeprecationsAndWarnings(new Setting[] { ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING }); } @@ -77,8 +77,8 @@ public void testSettingGetValueWhenBothAreConfigured() { .put("cluster.initial_cluster_manager_nodes", "node-a") .put("cluster.initial_master_nodes", "node-a, node-b") .build(); - assertEquals(ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(settings), Arrays.asList("node-a")); - assertEquals(ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.get(settings), Arrays.asList("node-a", "node-b")); + assertEquals(Arrays.asList("node-a"), ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(settings)); + assertEquals(Arrays.asList("node-a", "node-b"), ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.get(settings)); assertSettingDeprecationsAndWarnings(new Setting[] { ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING }); } } From 975501fcc753fafdd445b94bd343eec25cf01405 Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Tue, 15 Mar 2022 21:14:11 -0700 Subject: [PATCH 09/13] Rename initialMasterNodes in test method name Signed-off-by: Tianli Feng --- .../cluster/coordination/ClusterBootstrapServiceTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceTests.java b/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceTests.java index 97b2b0edc00a1..baa8c6abb8ba0 100644 --- a/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceTests.java @@ -422,7 +422,7 @@ public void testDoesNotBootstrapsOnNonMasterNode() { deterministicTaskQueue.runAllTasks(); } - public void testDoesNotBootstrapsIfLocalNodeNotInInitialMasterNodes() { + public void testDoesNotBootstrapsIfLocalNodeNotInInitialClusterManagerNodes() { ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( Settings.builder().putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), otherNode1.getName(), otherNode2.getName()).build(), transportService, From 754cd1a03ee995b37cbd1b54dda3889b3c2a3652 Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Wed, 16 Mar 2022 13:12:13 -0700 Subject: [PATCH 10/13] Use Settings.existsOrFallbackExists() instead of exists() Signed-off-by: Tianli Feng --- .../cluster/coordination/ClusterBootstrapService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/org/opensearch/cluster/coordination/ClusterBootstrapService.java b/server/src/main/java/org/opensearch/cluster/coordination/ClusterBootstrapService.java index dbc5e6dad9619..ce34a21e4adb6 100644 --- a/server/src/main/java/org/opensearch/cluster/coordination/ClusterBootstrapService.java +++ b/server/src/main/java/org/opensearch/cluster/coordination/ClusterBootstrapService.java @@ -114,7 +114,7 @@ public ClusterBootstrapService( Consumer votingConfigurationConsumer ) { if (DiscoveryModule.isSingleNodeDiscovery(settings)) { - if (INITIAL_MASTER_NODES_SETTING.exists(settings) || INITIAL_CLUSTER_MANAGER_NODES_SETTING.exists(settings)) { + if (INITIAL_CLUSTER_MANAGER_NODES_SETTING.existsOrFallbackExists(settings)) { // TODO: Remove variable 'initialClusterManagerSettingName' after removing MASTER_ROLE. String initialClusterManagerSettingName = INITIAL_CLUSTER_MANAGER_NODES_SETTING.exists(settings) ? INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey() From 2ee85dad58cb0b2f7c726e24820fc23e229346f8 Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Wed, 16 Mar 2022 17:03:02 -0700 Subject: [PATCH 11/13] Add both cluster.initial_cluster_manager_nodes and cluster.initial_master_nodes into an error message of BootstrapChecks Signed-off-by: Tianli Feng --- .../java/org/opensearch/bootstrap/BootstrapChecks.java | 9 ++++++--- .../org/opensearch/bootstrap/BootstrapChecksTests.java | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/server/src/main/java/org/opensearch/bootstrap/BootstrapChecks.java b/server/src/main/java/org/opensearch/bootstrap/BootstrapChecks.java index e2072cae84733..79019a73c69e3 100644 --- a/server/src/main/java/org/opensearch/bootstrap/BootstrapChecks.java +++ b/server/src/main/java/org/opensearch/bootstrap/BootstrapChecks.java @@ -64,6 +64,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING; import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING; import static org.opensearch.discovery.DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING; import static org.opensearch.discovery.SettingsBasedSeedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING; @@ -773,10 +774,12 @@ public BootstrapCheckResult check(BootstrapContext context) { return BootstrapCheckResult.failure( String.format( Locale.ROOT, - "the default discovery settings are unsuitable for production use; at least one of [%s] must be configured", - Stream.of(DISCOVERY_SEED_HOSTS_SETTING, DISCOVERY_SEED_PROVIDERS_SETTING, INITIAL_MASTER_NODES_SETTING) + // TODO: Remove ' / %s' from the error message after removing MASTER_ROLE, and update unit test. + "the default discovery settings are unsuitable for production use; at least one of [%s / %s] must be configured", + Stream.of(DISCOVERY_SEED_HOSTS_SETTING, DISCOVERY_SEED_PROVIDERS_SETTING, INITIAL_CLUSTER_MANAGER_NODES_SETTING) .map(Setting::getKey) - .collect(Collectors.joining(", ")) + .collect(Collectors.joining(", ")), + INITIAL_MASTER_NODES_SETTING.getKey() ) ); } diff --git a/server/src/test/java/org/opensearch/bootstrap/BootstrapChecksTests.java b/server/src/test/java/org/opensearch/bootstrap/BootstrapChecksTests.java index 00f9d4110e64c..d941c624509da 100644 --- a/server/src/test/java/org/opensearch/bootstrap/BootstrapChecksTests.java +++ b/server/src/test/java/org/opensearch/bootstrap/BootstrapChecksTests.java @@ -802,7 +802,7 @@ public void testDiscoveryConfiguredCheck() throws NodeValidationException { hasToString( containsString( "the default discovery settings are unsuitable for production use; at least one " - + "of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured" + + "of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_cluster_manager_nodes / cluster.initial_master_nodes] must be configured" ) ) ); From 7fc7c627425d1147aff8381a83e80455ab66bbc0 Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Thu, 17 Mar 2022 00:38:27 -0700 Subject: [PATCH 12/13] Update import not to use asterisk Signed-off-by: Tianli Feng --- .../cluster/coordination/ClusterBootstrapServiceTests.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceTests.java b/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceTests.java index baa8c6abb8ba0..67414c33be217 100644 --- a/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceTests.java @@ -56,7 +56,9 @@ import static java.util.Collections.emptyMap; import static java.util.Collections.emptySet; import static java.util.Collections.singletonList; -import static org.opensearch.cluster.coordination.ClusterBootstrapService.*; +import static org.opensearch.cluster.coordination.ClusterBootstrapService.BOOTSTRAP_PLACEHOLDER_PREFIX; +import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING; +import static org.opensearch.cluster.coordination.ClusterBootstrapService.UNCONFIGURED_BOOTSTRAP_TIMEOUT_SETTING; import static org.opensearch.common.settings.Settings.builder; import static org.opensearch.discovery.DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING; import static org.opensearch.discovery.SettingsBasedSeedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING; From bd7fdbe0019986c3e0e2af234286e85b31c24fbb Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Thu, 17 Mar 2022 00:54:53 -0700 Subject: [PATCH 13/13] Add the missing import of INITIAL_CLUSTER_MANAGER_NODES_SETTING Signed-off-by: Tianli Feng --- .../cluster/coordination/ClusterBootstrapServiceTests.java | 1 + 1 file changed, 1 insertion(+) diff --git a/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceTests.java b/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceTests.java index 67414c33be217..d8007933c2559 100644 --- a/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceTests.java @@ -57,6 +57,7 @@ import static java.util.Collections.emptySet; import static java.util.Collections.singletonList; import static org.opensearch.cluster.coordination.ClusterBootstrapService.BOOTSTRAP_PLACEHOLDER_PREFIX; +import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING; import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING; import static org.opensearch.cluster.coordination.ClusterBootstrapService.UNCONFIGURED_BOOTSTRAP_TIMEOUT_SETTING; import static org.opensearch.common.settings.Settings.builder;