-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Enforce cluster UUIDs #37775
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
Enforce cluster UUIDs #37775
Changes from 7 commits
9112741
965cbe5
afa6c1b
265eb44
7f8f97f
f93e0b4
c890ad4
861ad05
f67c82b
a0f3f79
1280e22
3dc2c62
23558df
b7be853
2697b44
9994b41
48dc33f
c3e0aa2
a13ffe9
bcbeb33
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -475,12 +475,25 @@ public interface PersistedState { | |
*/ | ||
default void markLastAcceptedConfigAsCommitted() { | ||
final ClusterState lastAcceptedState = getLastAcceptedState(); | ||
MetaData.Builder metaDataBuilder = null; | ||
if (lastAcceptedState.getLastAcceptedConfiguration().equals(lastAcceptedState.getLastCommittedConfiguration()) == false) { | ||
final CoordinationMetaData coordinationMetaData = CoordinationMetaData.builder(lastAcceptedState.coordinationMetaData()) | ||
.lastCommittedConfiguration(lastAcceptedState.getLastAcceptedConfiguration()) | ||
.build(); | ||
final MetaData metaData = MetaData.builder(lastAcceptedState.metaData()).coordinationMetaData(coordinationMetaData).build(); | ||
setLastAcceptedState(ClusterState.builder(lastAcceptedState).metaData(metaData).build()); | ||
if (metaDataBuilder == null) { | ||
metaDataBuilder = MetaData.builder(lastAcceptedState.metaData()); | ||
} | ||
metaDataBuilder.coordinationMetaData(coordinationMetaData); | ||
} | ||
if (lastAcceptedState.metaData().clusterUUID().equals(MetaData.UNKNOWN_CLUSTER_UUID) == false && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we commit a state without a cluster UUID? Feels like this should be an assertion to me. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the master node is a Zen1 node that has not recovered its state yet, that can unfortunately be the case (testMixedClusterFormation found this). I've added an assertion to that effect. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we write the assertion in a way that means we will have to remove it when Zen1 is no more? E.g. mention There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done in 2697b44 |
||
lastAcceptedState.metaData().clusterUUIDCommitted() == false) { | ||
if (metaDataBuilder == null) { | ||
metaDataBuilder = MetaData.builder(lastAcceptedState.metaData()); | ||
} | ||
metaDataBuilder.clusterUUIDCommitted(true); | ||
} | ||
if (metaDataBuilder != null) { | ||
setLastAcceptedState(ClusterState.builder(lastAcceptedState).metaData(metaDataBuilder).build()); | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,7 @@ | |
import java.util.function.BiConsumer; | ||
import java.util.function.Function; | ||
import java.util.function.LongSupplier; | ||
import java.util.function.Supplier; | ||
|
||
public class JoinHelper { | ||
|
||
|
@@ -84,7 +85,7 @@ public class JoinHelper { | |
final Set<Tuple<DiscoveryNode, JoinRequest>> pendingOutgoingJoins = ConcurrentCollections.newConcurrentSet(); | ||
|
||
public JoinHelper(Settings settings, AllocationService allocationService, MasterService masterService, | ||
TransportService transportService, LongSupplier currentTermSupplier, | ||
TransportService transportService, LongSupplier currentTermSupplier, Supplier<ClusterState> currentStateSupplier, | ||
BiConsumer<JoinRequest, JoinCallback> joinHandler, Function<StartJoinRequest, Join> joinLeaderInTerm, | ||
Collection<BiConsumer<DiscoveryNode, ClusterState>> joinValidators) { | ||
this.masterService = masterService; | ||
|
@@ -132,6 +133,13 @@ public ClusterTasksResult<JoinTaskExecutor.Task> execute(ClusterState currentSta | |
transportService.registerRequestHandler(VALIDATE_JOIN_ACTION_NAME, | ||
MembershipAction.ValidateJoinRequest::new, ThreadPool.Names.GENERIC, | ||
(request, channel, task) -> { | ||
final ClusterState localState = currentStateSupplier.get(); | ||
if (localState.metaData().clusterUUIDCommitted() && | ||
localState.metaData().clusterUUID().equals(request.getState().metaData().clusterUUID()) == false) { | ||
throw new CoordinationStateRejectedException("join validation on cluster state" + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the reason why we log warning message in |
||
" with a different cluster uuid " + request.getState().metaData().clusterUUID() + | ||
" than local cluster uuid " + localState.metaData().clusterUUID() + ", rejecting"); | ||
} | ||
joinValidators.forEach(action -> action.accept(transportService.getLocalNode(), request.getState())); | ||
channel.sendResponse(Empty.INSTANCE); | ||
}); | ||
|
Uh oh!
There was an error while loading. Please reload this page.