Skip to content

Commit cea8b3b

Browse files
committed
Rebooted master-ineligibles should not bootstrap (#55302)
In #55298 we saw a failure of `CoordinationStateTests#testSafety` in which a single master-eligible node is bootstrapped, then rebooted as a master-ineligible node (losing its persistent state) and then rebooted as a master-eligible node and bootstrapped again. This happens because this test loses too much of the persistent state; in fact once bootstrapped the node would not allow itself to be bootstrapped again. This commit adjusts the test logic to reflect this. Closes #55298
1 parent 3992341 commit cea8b3b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

test/framework/src/main/java/org/elasticsearch/cluster/coordination/CoordinationStateTestCluster.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,14 @@ static class ClusterNode {
106106

107107
void reboot() {
108108
if (localNode.isMasterNode() == false && rarely()) {
109-
// master-ineligible nodes can't be trusted to persist the cluster state properly
110-
persistedState = new InMemoryPersistedState(0L,
111-
clusterState(0L, 0L, localNode, CoordinationMetaData.VotingConfiguration.EMPTY_CONFIG,
112-
CoordinationMetaData.VotingConfiguration.EMPTY_CONFIG, 0L));
109+
// master-ineligible nodes can't be trusted to persist the cluster state properly, but will not lose the fact that they
110+
// were bootstrapped
111+
final CoordinationMetaData.VotingConfiguration votingConfiguration
112+
= persistedState.getLastAcceptedState().getLastAcceptedConfiguration().isEmpty()
113+
? CoordinationMetaData.VotingConfiguration.EMPTY_CONFIG
114+
: CoordinationMetaData.VotingConfiguration.MUST_JOIN_ELECTED_MASTER;
115+
persistedState
116+
= new InMemoryPersistedState(0L, clusterState(0L, 0L, localNode, votingConfiguration, votingConfiguration, 0L));
113117
}
114118

115119
final Set<DiscoveryNodeRole> roles = new HashSet<>(localNode.getRoles());

0 commit comments

Comments
 (0)