Skip to content

Commit 5acabc4

Browse files
DISCOVERY: Use Realistic Num. of Min Master Nodes (#34854)
* DISCOVERY: Use Realistic Num. of Min Master Nodes * With all 3 nodes starting in parallel 2 nodes can win a master election and start waiting for nodes to join when started in parallel. We wait for 30s on the rest tests for the cluster health endpoint to show 3 nodes which breaks if one of the master nodes itself waits for 30s for joining nodes, waiting for 5 seconds fixes the issue and allows us to run with `minimum master nodes < node count` * relates #33675
1 parent 9f87fdc commit 5acabc4

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ class ClusterConfiguration {
6969
*/
7070
@Input
7171
Closure<Integer> minimumMasterNodes = {
72-
return getNumNodes() > 1 ? getNumNodes() : -1
72+
if (bwcVersion != null && bwcVersion.before("6.5.0-SNAPSHOT")) {
73+
return numNodes > 1 ? numNodes : -1
74+
} else {
75+
return numNodes > 1 ? numNodes.intdiv(2) + 1 : -1
76+
}
7377
}
7478

7579
@Input

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

+7
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,13 @@ class ClusterFormationTasks {
343343
// this will also allow new and old nodes in the BWC case to become the master
344344
esConfig['discovery.initial_state_timeout'] = '0s'
345345
}
346+
if (esConfig.containsKey('discovery.zen.master_election.wait_for_joins_timeout') == false) {
347+
// If a node decides to become master based on partial information from the pinging, don't let it hang for 30 seconds to correct
348+
// its mistake. Instead, only wait 5s to do another round of pinging.
349+
// This is necessary since we use 30s as the default timeout in REST requests waiting for cluster formation
350+
// so we need to bail quicker than the default 30s for the cluster to form in time.
351+
esConfig['discovery.zen.master_election.wait_for_joins_timeout'] = '5s'
352+
}
346353
esConfig['node.max_local_storage_nodes'] = node.config.numNodes
347354
esConfig['http.port'] = node.config.httpPort
348355
esConfig['transport.tcp.port'] = node.config.transportPort

0 commit comments

Comments
 (0)