Skip to content

Commit

Permalink
Rebooted master-ineligibles should not bootstrap (#55302)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
DaveCTurner committed Apr 20, 2020
1 parent 3992341 commit cea8b3b
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,14 @@ static class ClusterNode {

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

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

0 comments on commit cea8b3b

Please sign in to comment.