Skip to content

Commit 81c443c

Browse files
authored
Deprecate minimum_master_nodes (#37868)
Today we pass `discovery.zen.minimum_master_nodes` to nodes started up in tests, but for 7.x nodes this setting is not required as it has no effect. This commit removes this setting so that nodes are started with more realistic configurations, and deprecates it.
1 parent 6a78b6a commit 81c443c

File tree

23 files changed

+140
-278
lines changed

23 files changed

+140
-278
lines changed

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -373,18 +373,15 @@ class ClusterFormationTasks {
373373
'path.repo' : "${node.sharedDir}/repo",
374374
'path.shared_data' : "${node.sharedDir}/",
375375
// Define a node attribute so we can test that it exists
376-
'node.attr.testattr' : 'test'
376+
'node.attr.testattr' : 'test',
377+
// Don't wait for state, just start up quickly. This will also allow new and old nodes in the BWC case to become the master
378+
'discovery.initial_state_timeout' : '0s'
377379
]
378380
int minimumMasterNodes = node.config.minimumMasterNodes.call()
379-
if (minimumMasterNodes > 0) {
381+
if (node.nodeVersion.before("7.0.0") && minimumMasterNodes > 0) {
380382
esConfig['discovery.zen.minimum_master_nodes'] = minimumMasterNodes
381383
}
382-
if (minimumMasterNodes > 1) {
383-
// don't wait for state.. just start up quickly
384-
// this will also allow new and old nodes in the BWC case to become the master
385-
esConfig['discovery.initial_state_timeout'] = '0s'
386-
}
387-
if (esConfig.containsKey('discovery.zen.master_election.wait_for_joins_timeout') == false) {
384+
if (node.nodeVersion.before("7.0.0") && esConfig.containsKey('discovery.zen.master_election.wait_for_joins_timeout') == false) {
388385
// If a node decides to become master based on partial information from the pinging, don't let it hang for 30 seconds to correct
389386
// its mistake. Instead, only wait 5s to do another round of pinging.
390387
// This is necessary since we use 30s as the default timeout in REST requests waiting for cluster formation

docs/reference/migration/migrate_7_0/discovery.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ settings summary>> for an example, and the
1313
<<modules-discovery-bootstrap-cluster,cluster bootstrapping reference
1414
documentation>> describes this setting in more detail.
1515

16-
The `discovery.zen.minimum_master_nodes` setting is required during a rolling
17-
upgrade from 6.x, but can be removed in all other circumstances.
16+
The `discovery.zen.minimum_master_nodes` setting is permitted, but ignored, on
17+
7.x nodes.
1818

1919
[float]
2020
==== Removing master-eligible nodes sometimes requires voting exclusions

modules/transport-netty4/src/test/java/org/elasticsearch/rest/discovery/Zen2RestApiIT.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@
3333
import org.elasticsearch.cluster.routing.UnassignedInfo;
3434
import org.elasticsearch.common.Priority;
3535
import org.elasticsearch.common.settings.Settings;
36-
import org.elasticsearch.common.settings.Settings.Builder;
3736
import org.elasticsearch.common.unit.TimeValue;
38-
import org.elasticsearch.discovery.zen.ElectMasterService;
3937
import org.elasticsearch.http.HttpServerTransport;
4038
import org.elasticsearch.test.ESIntegTestCase;
4139
import org.elasticsearch.test.InternalTestCluster;
@@ -58,11 +56,7 @@ public class Zen2RestApiIT extends ESNetty4IntegTestCase {
5856

5957
@Override
6058
protected Settings nodeSettings(int nodeOrdinal) {
61-
final Builder builder = Settings.builder().put(super.nodeSettings(nodeOrdinal))
62-
.put(TestZenDiscovery.USE_ZEN2.getKey(), true)
63-
.put(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), Integer.MAX_VALUE);
64-
65-
return builder.build();
59+
return Settings.builder().put(super.nodeSettings(nodeOrdinal)).put(TestZenDiscovery.USE_ZEN2.getKey(), true).build();
6660
}
6761

6862
@Override

plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryUpdateSettingsTests.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222

2323
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse;
24+
import org.elasticsearch.common.UUIDs;
2425
import org.elasticsearch.common.settings.Settings;
2526
import org.elasticsearch.discovery.DiscoveryModule;
2627
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
@@ -41,13 +42,14 @@ public void testMinimumMasterNodesStart() {
4142
.build();
4243
internalCluster().startNode(nodeSettings);
4344

44-
// We try to update minimum_master_nodes now
45-
ClusterUpdateSettingsResponse response = client().admin().cluster().prepareUpdateSettings()
46-
.setPersistentSettings(Settings.builder().put("discovery.zen.minimum_master_nodes", 1))
47-
.setTransientSettings(Settings.builder().put("discovery.zen.minimum_master_nodes", 1))
45+
// We try to update a setting now
46+
final String expectedValue = UUIDs.randomBase64UUID(random());
47+
final String settingName = "cluster.routing.allocation.exclude.any_attribute";
48+
final ClusterUpdateSettingsResponse response = client().admin().cluster().prepareUpdateSettings()
49+
.setPersistentSettings(Settings.builder().put(settingName, expectedValue))
4850
.get();
4951

50-
Integer min = response.getPersistentSettings().getAsInt("discovery.zen.minimum_master_nodes", null);
51-
assertThat(min, is(1));
52+
final String value = response.getPersistentSettings().get(settingName);
53+
assertThat(value, is(expectedValue));
5254
}
5355
}

qa/logging-config/src/test/java/org/elasticsearch/qa/custom_logging/CustomLoggingConfigIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
* The intention is to confirm that users can still run their Elasticsearch instances with previous configurations.
4141
*/
4242
public class CustomLoggingConfigIT extends ESRestTestCase {
43-
private static final String NODE_STARTED = ".*node-0.*cluster.uuid.*node.id.*started.*";
43+
private static final String NODE_STARTED = ".*node-0.*cluster.uuid.*node.id.*recovered.*cluster_state.*";
4444

4545
public void testSuccessfulStartupWithCustomConfig() throws Exception {
4646
assertBusy(() -> {

qa/rolling-upgrade/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ for (Version version : bwcVersions.wireCompatible) {
7777
dependsOn lastRunner, "${baseName}#oldClusterTestCluster#node${stopNode}.stop"
7878
clusterName = 'rolling-upgrade'
7979
otherUnicastHostAddresses = { getOtherUnicastHostAddresses() }
80-
minimumMasterNodes = { 2 }
8180
autoSetInitialMasterNodes = false
8281
/* Override the data directory so the new node always gets the node we
8382
* just stopped's data directory. */

rest-api-spec/src/main/resources/rest-api-spec/test/cluster.put_settings/10_basic.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@
44
cluster.put_settings:
55
body:
66
transient:
7-
discovery.zen.minimum_master_nodes: 1
7+
cluster.routing.allocation.enable: "none"
88
flat_settings: true
99

10-
- match: {transient: {discovery.zen.minimum_master_nodes: "1"}}
10+
- match: {transient: {cluster.routing.allocation.enable: "none"}}
1111

1212
- do:
1313
cluster.get_settings:
1414
flat_settings: true
1515

16-
- match: {transient: {discovery.zen.minimum_master_nodes: "1"}}
16+
- match: {transient: {cluster.routing.allocation.enable: "none"}}
1717

1818
- do:
1919
cluster.put_settings:
2020
body:
2121
transient:
22-
discovery.zen.minimum_master_nodes: null
22+
cluster.routing.allocation.enable: null
2323
flat_settings: true
2424

2525
- match: {transient: {}}
@@ -35,22 +35,22 @@
3535
cluster.put_settings:
3636
body:
3737
persistent:
38-
cluster.routing.allocation.disk.threshold_enabled: false
38+
cluster.routing.allocation.enable: "none"
3939
flat_settings: true
4040

41-
- match: {persistent: {cluster.routing.allocation.disk.threshold_enabled: "false"}}
41+
- match: {persistent: {cluster.routing.allocation.enable: "none"}}
4242

4343
- do:
4444
cluster.get_settings:
4545
flat_settings: true
4646

47-
- match: {persistent: {cluster.routing.allocation.disk.threshold_enabled: "false"}}
47+
- match: {persistent: {cluster.routing.allocation.enable: "none"}}
4848

4949
- do:
5050
cluster.put_settings:
5151
body:
5252
persistent:
53-
cluster.routing.allocation.disk.threshold_enabled: null
53+
cluster.routing.allocation.enable: null
5454
flat_settings: true
5555

5656
- match: {persistent: {}}

server/src/main/java/org/elasticsearch/discovery/zen/ElectMasterService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class ElectMasterService {
4242
private static final Logger logger = LogManager.getLogger(ElectMasterService.class);
4343

4444
public static final Setting<Integer> DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING =
45-
Setting.intSetting("discovery.zen.minimum_master_nodes", -1, Property.Dynamic, Property.NodeScope);
45+
Setting.intSetting("discovery.zen.minimum_master_nodes", -1, Property.Dynamic, Property.NodeScope, Property.Deprecated);
4646

4747
private volatile int minimumMasterNodes;
4848

server/src/test/java/org/elasticsearch/action/admin/indices/exists/IndicesExistsIT.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import org.elasticsearch.common.settings.Settings;
2424
import org.elasticsearch.common.unit.TimeValue;
2525
import org.elasticsearch.discovery.MasterNotDiscoveredException;
26-
import org.elasticsearch.discovery.zen.ElectMasterService;
2726
import org.elasticsearch.gateway.GatewayService;
2827
import org.elasticsearch.test.ESIntegTestCase;
2928
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
@@ -51,8 +50,7 @@ protected List<Settings> addExtraClusterBootstrapSettings(List<Settings> allNode
5150

5251
public void testIndexExistsWithBlocksInPlace() throws IOException {
5352
Settings settings = Settings.builder()
54-
.put(GatewayService.RECOVER_AFTER_NODES_SETTING.getKey(), 99)
55-
.put(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), Integer.MAX_VALUE).build();
53+
.put(GatewayService.RECOVER_AFTER_NODES_SETTING.getKey(), 99).build();
5654
String node = internalCluster().startNode(settings);
5755

5856
assertThrows(client(node).admin().indices().prepareExists("test").setMasterNodeTimeout(TimeValue.timeValueSeconds(0)),

server/src/test/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,13 @@
2626
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
2727
import org.elasticsearch.client.Client;
2828
import org.elasticsearch.cluster.coordination.ClusterBootstrapService;
29+
import org.elasticsearch.cluster.coordination.FailedToCommitClusterStateException;
2930
import org.elasticsearch.cluster.metadata.MetaData;
3031
import org.elasticsearch.cluster.node.DiscoveryNode;
3132
import org.elasticsearch.cluster.service.ClusterService;
3233
import org.elasticsearch.common.Priority;
3334
import org.elasticsearch.common.settings.Settings;
3435
import org.elasticsearch.discovery.DiscoverySettings;
35-
import org.elasticsearch.cluster.coordination.FailedToCommitClusterStateException;
36-
import org.elasticsearch.discovery.zen.ElectMasterService;
3736
import org.elasticsearch.discovery.zen.ZenDiscovery;
3837
import org.elasticsearch.index.query.QueryBuilders;
3938
import org.elasticsearch.node.Node;
@@ -102,7 +101,6 @@ public void testTwoNodesNoMasterBlock() throws Exception {
102101
bootstrapNodeId = 2;
103102

104103
Settings settings = Settings.builder()
105-
.put("discovery.zen.minimum_master_nodes", 2)
106104
.put(ZenDiscovery.PING_TIMEOUT_SETTING.getKey(), "200ms")
107105
.put("discovery.initial_state_timeout", "500ms")
108106
.build();
@@ -237,7 +235,6 @@ public void testThreeNodesNoMasterBlock() throws Exception {
237235
bootstrapNodeId = 3;
238236

239237
Settings settings = Settings.builder()
240-
.put("discovery.zen.minimum_master_nodes", 3)
241238
.put(ZenDiscovery.PING_TIMEOUT_SETTING.getKey(), "1s")
242239
.put("discovery.initial_state_timeout", "500ms")
243240
.build();
@@ -316,11 +313,9 @@ public void testCannotCommitStateThreeNodes() throws Exception {
316313
Settings settings = Settings.builder()
317314
.put(ZenDiscovery.PING_TIMEOUT_SETTING.getKey(), "200ms")
318315
.put("discovery.initial_state_timeout", "500ms")
319-
.put(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), 2)
320316
.put(DiscoverySettings.COMMIT_TIMEOUT_SETTING.getKey(), "100ms") // speed things up
321317
.build();
322318

323-
324319
internalCluster().startNodes(3, settings);
325320
ensureGreen(); // ensure cluster state is recovered before we disrupt things
326321

0 commit comments

Comments
 (0)