Skip to content

Commit

Permalink
Deprecated reserved node id '_must_join_elected_master_' that used by…
Browse files Browse the repository at this point in the history
… DetachClusterCommand and replace with '_must_join_elected_cluster_manager_' (#3138)

Signed-off-by: Tianli Feng <[email protected]>
  • Loading branch information
Tianli Feng authored May 3, 2022
1 parent be2a9ae commit 97a6f2c
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ String getDescription() {

assert clusterState.getLastCommittedConfiguration().isEmpty() == false;

if (clusterState.getLastCommittedConfiguration().equals(VotingConfiguration.MUST_JOIN_ELECTED_MASTER)) {
if (clusterState.getLastCommittedConfiguration().equals(VotingConfiguration.MUST_JOIN_ELECTED_MASTER)
|| clusterState.getLastCommittedConfiguration().equals(VotingConfiguration.MUST_JOIN_ELECTED_CLUSTER_MANAGER)) {
return String.format(
Locale.ROOT,
"cluster-manager not discovered yet and this node was detached from its previous cluster, have discovered %s; %s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,16 @@ public String toString() {
public static class VotingConfiguration implements Writeable, ToXContentFragment {

public static final VotingConfiguration EMPTY_CONFIG = new VotingConfiguration(Collections.emptySet());
/**
* @deprecated As of 2.0, because supporting inclusive language, replaced by {@link #MUST_JOIN_ELECTED_CLUSTER_MANAGER}
*/
@Deprecated
public static final VotingConfiguration MUST_JOIN_ELECTED_MASTER = new VotingConfiguration(
Collections.singleton("_must_join_elected_master_")
);
public static final VotingConfiguration MUST_JOIN_ELECTED_CLUSTER_MANAGER = new VotingConfiguration(
Collections.singleton("_must_join_elected_cluster_manager_")
);

private final Set<String> nodeIds;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ protected void processNodePaths(Terminal terminal, Path[] dataPaths, int nodeLoc
// package-private for tests
static Metadata updateMetadata(Metadata oldMetadata) {
final CoordinationMetadata coordinationMetadata = CoordinationMetadata.builder()
.lastAcceptedConfiguration(CoordinationMetadata.VotingConfiguration.MUST_JOIN_ELECTED_MASTER)
.lastCommittedConfiguration(CoordinationMetadata.VotingConfiguration.MUST_JOIN_ELECTED_MASTER)
.lastAcceptedConfiguration(CoordinationMetadata.VotingConfiguration.MUST_JOIN_ELECTED_CLUSTER_MANAGER)
.lastCommittedConfiguration(CoordinationMetadata.VotingConfiguration.MUST_JOIN_ELECTED_CLUSTER_MANAGER)
.term(0)
.build();
return Metadata.builder(oldMetadata).coordinationMetadata(coordinationMetadata).clusterUUIDCommitted(false).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ public void testDescriptionAfterDetachCluster() {

final ClusterState clusterState = state(
localNode,
VotingConfiguration.MUST_JOIN_ELECTED_MASTER.getNodeIds().toArray(new String[0])
VotingConfiguration.MUST_JOIN_ELECTED_CLUSTER_MANAGER.getNodeIds().toArray(new String[0])
);

assertThat(
Expand Down Expand Up @@ -899,4 +899,35 @@ public void testDescriptionAfterBootstrapping() {
);

}

/*
* Validate the Cluster State with deprecated VotingConfiguration.MUST_JOIN_ELECTED_MASTER can get correct ClusterFormationState description.
*/
public void testDescriptionAfterDetachClusterWithDeprecatedMasterVotingConfiguration() {
final DiscoveryNode localNode = new DiscoveryNode("local", buildNewFakeTransportAddress(), Version.CURRENT);

final ClusterState clusterState = state(
localNode,
VotingConfiguration.MUST_JOIN_ELECTED_MASTER.getNodeIds().toArray(new String[0])
);

assertThat(
new ClusterFormationState(
Settings.EMPTY,
clusterState,
emptyList(),
emptyList(),
0L,
electionStrategy,
new StatusInfo(HEALTHY, "healthy-info")
).getDescription(),
is(
"cluster-manager not discovered yet and this node was detached from its previous cluster, "
+ "have discovered []; "
+ "discovery will continue using [] from hosts providers and ["
+ localNode
+ "] from last-known cluster state; node term 0, last-accepted version 0 in term 0"
)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ void reboot() {
.getLastAcceptedConfiguration()
.isEmpty()
? CoordinationMetadata.VotingConfiguration.EMPTY_CONFIG
: CoordinationMetadata.VotingConfiguration.MUST_JOIN_ELECTED_MASTER;
: CoordinationMetadata.VotingConfiguration.MUST_JOIN_ELECTED_CLUSTER_MANAGER;
persistedState = new InMemoryPersistedState(
0L,
clusterState(0L, 0L, localNode, votingConfiguration, votingConfiguration, 0L)
Expand Down

0 comments on commit 97a6f2c

Please sign in to comment.