Skip to content

Commit

Permalink
Fix issue that deprecated setting 'cluster.initial_master_nodes' is n…
Browse files Browse the repository at this point in the history
…ot identified in node bootstrap check (opensearch-project#2779)

* Fix issue that deprecated setting 'cluster.initial_master_nodes' is not identified during node bootstrap

Signed-off-by: Tianli Feng <ftianli@amazon.com>

* Restore a variable name

Signed-off-by: Tianli Feng <ftianli@amazon.com>
  • Loading branch information
Tianli Feng committed Apr 6, 2022
1 parent ce5c55d commit dd24e17
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ public ClusterBootstrapService(
BooleanSupplier isBootstrappedSupplier,
Consumer<VotingConfiguration> votingConfigurationConsumer
) {
// 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();
if (DiscoveryModule.isSingleNodeDiscovery(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()
: INITIAL_MASTER_NODES_SETTING.getKey();
throw new IllegalArgumentException(
"setting ["
+ initialClusterManagerSettingName
Expand All @@ -145,7 +145,7 @@ public ClusterBootstrapService(
bootstrapRequirements = unmodifiableSet(new LinkedHashSet<>(initialMasterNodes));
if (bootstrapRequirements.size() != initialMasterNodes.size()) {
throw new IllegalArgumentException(
"setting [" + INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey() + "] contains duplicates: " + initialMasterNodes
"setting [" + initialClusterManagerSettingName + "] contains duplicates: " + initialMasterNodes
);
}
unconfiguredBootstrapTimeout = discoveryIsConfigured(settings) ? null : UNCONFIGURED_BOOTSTRAP_TIMEOUT_SETTING.get(settings);
Expand All @@ -163,7 +163,8 @@ public static boolean discoveryIsConfigured(Settings settings) {
LEGACY_DISCOVERY_HOSTS_PROVIDER_SETTING,
DISCOVERY_SEED_HOSTS_SETTING,
LEGACY_DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING,
INITIAL_CLUSTER_MANAGER_NODES_SETTING
INITIAL_CLUSTER_MANAGER_NODES_SETTING,
INITIAL_MASTER_NODES_SETTING
).anyMatch(s -> s.exists(settings));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -818,5 +818,7 @@ public void testDiscoveryConfiguredCheck() throws NodeValidationException {
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()));
// Validate the deprecated setting is still valid during the node bootstrap.
ensureChecksPass.accept(Settings.builder().putList(ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.getKey()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,19 @@ public void testDoesNothingByDefaultIfSeedHostsConfigured() {
testDoesNothingWithSettings(builder().putList(DISCOVERY_SEED_HOSTS_SETTING.getKey()));
}

public void testDoesNothingByDefaultIfMasterNodesConfigured() {
public void testDoesNothingByDefaultIfClusterManagerNodesConfigured() {
testDoesNothingWithSettings(builder().putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey()));
}

// Validate the deprecated setting is still valid during the cluster bootstrap.
public void testDoesNothingByDefaultIfMasterNodesConfigured() {
testDoesNothingWithSettings(builder().putList(INITIAL_MASTER_NODES_SETTING.getKey()));
assertWarnings(
"[cluster.initial_master_nodes] setting was deprecated in OpenSearch and will be removed in a future release! "
+ "See the breaking changes documentation for the next major version."
);
}

public void testDoesNothingByDefaultOnMasterIneligibleNodes() {
localNode = new DiscoveryNode(
"local",
Expand Down

0 comments on commit dd24e17

Please sign in to comment.