-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Merged
Merged
Enforce cluster UUIDs #37775
Changes from 11 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
9112741
Enforce cluster uuid
ywelsch 965cbe5
Merge remote-tracking branch 'elastic/master' into enforce-clusteruuid
ywelsch afa6c1b
more tests
ywelsch 265eb44
wip
ywelsch 7f8f97f
seems to work now
ywelsch f93e0b4
add warning log
ywelsch c890ad4
fix testMixedClusterFormation
ywelsch 861ad05
fix test
ywelsch f67c82b
Merge remote-tracking branch 'elastic/master' into enforce-clusteruuid
ywelsch a0f3f79
feedback
ywelsch 1280e22
add test
ywelsch 3dc2c62
use constant
ywelsch 23558df
add assertion
ywelsch b7be853
longer fail time
ywelsch 2697b44
rewrite assertion using Zen1 BWC term
ywelsch 9994b41
Merge remote-tracking branch 'elastic/master' into enforce-clusteruuid
ywelsch 48dc33f
Merge remote-tracking branch 'elastic/master' into enforce-clusteruuid
ywelsch c3e0aa2
add TODO
ywelsch a13ffe9
Merge remote-tracking branch 'elastic/master' into enforce-clusteruuid
ywelsch bcbeb33
Merge remote-tracking branch 'elastic/master' into enforce-clusteruuid
ywelsch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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 comment
The 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 comment
The 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
ZEN1_BWC_TERM
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in 2697b44