Deprecate setting 'cluster.initial_master_nodes' and introduce the alternative setting 'cluster.initial_cluster_manager_nodes' (#2463)

* Deprecate setting cluster.initial_master_nodes, and add setting cluster.initial_cluster_manager_nodes

Signed-off-by: Tianli Feng <ftianli@amazon.com>
This commit is contained in:
Tianli Feng 2022-03-18 14:55:49 -07:00 committed by GitHub
parent 9c4d7d92b3
commit 19eadb46ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 202 additions and 68 deletions

View File

@ -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_master_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 {

View File

@ -361,7 +361,12 @@ public class OpenSearchCluster implements TestClusterConfiguration, Named {
.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 + "]");
// 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", "[]");

View File

@ -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=opensearch-1,opensearch-2
- discovery.seed_hosts=opensearch-1:9300
- cluster.name=opensearch
- bootstrap.memory_lock=true

View File

@ -67,9 +67,9 @@ ${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_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.
#

View File

@ -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

View File

@ -422,7 +422,7 @@ public class ClusterDisruptionIT extends AbstractDisruptionTestCase {
@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

View File

@ -83,7 +83,7 @@ import java.util.Map;
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;
@ -383,7 +383,7 @@ public class RecoveryFromGatewayIT extends OpenSearchIntegTestCase {
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();
}

View File

@ -64,6 +64,7 @@ import java.util.regex.Pattern;
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 @@ final class BootstrapChecks {
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()
)
);
}

View File

@ -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<List<String>> INITIAL_CLUSTER_MANAGER_NODES_SETTING = Setting.listSetting(
"cluster.initial_cluster_manager_nodes",
INITIAL_MASTER_NODES_SETTING,
Function.identity(),
Property.NodeScope
);
@ -105,10 +114,14 @@ public class ClusterBootstrapService {
Consumer<VotingConfiguration> votingConfigurationConsumer
) {
if (DiscoveryModule.isSingleNodeDiscovery(settings)) {
if (INITIAL_MASTER_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()
: INITIAL_MASTER_NODES_SETTING.getKey();
throw new IllegalArgumentException(
"setting ["
+ INITIAL_MASTER_NODES_SETTING.getKey()
+ initialClusterManagerSettingName
+ "] is not allowed when ["
+ DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey()
+ "] is set to ["
@ -128,11 +141,11 @@ public class ClusterBootstrapService {
bootstrapRequirements = Collections.singleton(Node.NODE_NAME_SETTING.get(settings));
unconfiguredBootstrapTimeout = null;
} else {
final List<String> initialMasterNodes = INITIAL_MASTER_NODES_SETTING.get(settings);
final List<String> 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 +163,7 @@ public class ClusterBootstrapService {
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));
}

View File

@ -56,7 +56,7 @@ import java.util.function.Supplier;
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 @@ public class ClusterFormationFailureHelper {
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)
);
}

View File

@ -539,7 +539,8 @@ public final class ClusterSettings extends AbstractScopedSettings {
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,

View File

@ -802,7 +802,7 @@ public class BootstrapChecksTests extends AbstractBootstrapCheckTestCase {
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"
)
)
);
@ -815,7 +815,7 @@ public class BootstrapChecksTests extends AbstractBootstrapCheckTestCase {
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()));
}

View File

@ -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<Setting<?>> 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_MASTER_NODES_SETTING.get(Settings.EMPTY),
ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_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(Arrays.asList("node-a"), ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(settings));
assertEquals(
ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.getDefault(Settings.EMPTY),
ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.get(settings)
);
}
/**
* 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(Arrays.asList("node-a"), ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(settings));
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(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 });
}
}

View File

@ -57,6 +57,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.INITIAL_MASTER_NODES_SETTING;
import static org.opensearch.cluster.coordination.ClusterBootstrapService.UNCONFIGURED_BOOTSTRAP_TIMEOUT_SETTING;
import static org.opensearch.common.settings.Settings.builder;
@ -166,7 +167,7 @@ public class ClusterBootstrapServiceTests extends OpenSearchTestCase {
}
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 +198,7 @@ public class ClusterBootstrapServiceTests extends OpenSearchTestCase {
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 +206,7 @@ public class ClusterBootstrapServiceTests extends OpenSearchTestCase {
);
});
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 +215,7 @@ public class ClusterBootstrapServiceTests extends OpenSearchTestCase {
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 +243,7 @@ public class ClusterBootstrapServiceTests extends OpenSearchTestCase {
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 +277,7 @@ public class ClusterBootstrapServiceTests extends OpenSearchTestCase {
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 +326,7 @@ public class ClusterBootstrapServiceTests extends OpenSearchTestCase {
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 +343,7 @@ public class ClusterBootstrapServiceTests extends OpenSearchTestCase {
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 +366,7 @@ public class ClusterBootstrapServiceTests extends OpenSearchTestCase {
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 +389,7 @@ public class ClusterBootstrapServiceTests extends OpenSearchTestCase {
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 +413,7 @@ public class ClusterBootstrapServiceTests extends OpenSearchTestCase {
);
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()),
@ -424,9 +425,9 @@ public class ClusterBootstrapServiceTests extends OpenSearchTestCase {
deterministicTaskQueue.runAllTasks();
}
public void testDoesNotBootstrapsIfLocalNodeNotInInitialMasterNodes() {
public void testDoesNotBootstrapsIfLocalNodeNotInInitialClusterManagerNodes() {
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 +440,7 @@ public class ClusterBootstrapServiceTests extends OpenSearchTestCase {
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 +456,7 @@ public class ClusterBootstrapServiceTests extends OpenSearchTestCase {
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 +481,7 @@ public class ClusterBootstrapServiceTests extends OpenSearchTestCase {
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 +503,7 @@ public class ClusterBootstrapServiceTests extends OpenSearchTestCase {
);
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 +543,7 @@ public class ClusterBootstrapServiceTests extends OpenSearchTestCase {
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 +559,7 @@ public class ClusterBootstrapServiceTests extends OpenSearchTestCase {
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 +575,7 @@ public class ClusterBootstrapServiceTests extends OpenSearchTestCase {
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 +590,7 @@ public class ClusterBootstrapServiceTests extends OpenSearchTestCase {
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 +607,7 @@ public class ClusterBootstrapServiceTests extends OpenSearchTestCase {
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()),
@ -670,6 +671,29 @@ public class ClusterBootstrapServiceTests extends OpenSearchTestCase {
);
}
/**
* 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())
.put(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), "test");
assertThat(
expectThrows(
IllegalArgumentException.class,
() -> new ClusterBootstrapService(settings.build(), transportService, () -> emptyList(), () -> false, vc -> fail())
).getMessage(),
containsString(
"setting ["
+ INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey()
+ "] is not allowed when [discovery.type] is set to [single-node]"
)
);
}
public void testFailBootstrapNonMasterEligibleNodeWithSingleNodeDiscovery() {
final Settings.Builder settings = Settings.builder()
.put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), DiscoveryModule.SINGLE_NODE_DISCOVERY_TYPE)

View File

@ -56,7 +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_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;
@ -329,7 +329,7 @@ public class ClusterFormationFailureHelperTests extends OpenSearchTestCase {
).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 class ClusterFormationFailureHelperTests extends OpenSearchTestCase {
).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 class ClusterFormationFailureHelperTests extends OpenSearchTestCase {
).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 ["
@ -382,7 +382,7 @@ public class ClusterFormationFailureHelperTests extends OpenSearchTestCase {
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(),

View File

@ -64,7 +64,7 @@ import java.util.Arrays;
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 @@ public class IndicesServiceCloseTests extends OpenSearchTestCase {
// 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();

View File

@ -1445,8 +1445,8 @@ public class SnapshotResiliencyTests extends OpenSearchTestCase {
.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()

View File

@ -1089,8 +1089,8 @@ public class AbstractCoordinatorTestCase extends OpenSearchTestCase {
: 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(

View File

@ -157,7 +157,7 @@ import java.util.stream.Stream;
import static org.apache.lucene.tests.util.LuceneTestCase.TEST_NIGHTLY;
import static org.apache.lucene.tests.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 @@ public final class InternalTestCluster extends TestCluster {
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 @@ public final class InternalTestCluster extends TestCluster {
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 @@ public final class InternalTestCluster extends TestCluster {
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 @@ public final class InternalTestCluster extends TestCluster {
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 final class InternalTestCluster extends TestCluster {
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;
}

View File

@ -78,7 +78,7 @@ import java.util.Collection;
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 @@ public abstract class OpenSearchSingleNodeTestCase extends OpenSearchTestCase {
// 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();