Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.x] Deprecated reserved node id '_must_join_elected_master_' that used by DetachClusterCommand and replace with '_must_join_elected_cluster_manager_' #3138

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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