-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Atomically update cluster state with decommission status and corresponding action #5093
Merged
Bukhtawar
merged 29 commits into
opensearch-project:main
from
imRishN:decommission/init-merge
Dec 13, 2022
Merged
Changes from 26 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
236940f
Abstract helpers from TransportVotingConfigExclusion
imRishN b634138
Update INIT and exclusion in one call
imRishN 36d981d
use max voting config exclusion count
imRishN 29a1d04
Fix spotless check
imRishN 39f058f
fix
imRishN e855f70
Remove transport call for exclusion
imRishN 11e3c81
Abstract clear exclusion
imRishN fe59288
Use controller for status update and account for terminal status
imRishN a8d4fd6
atomic recommission
imRishN 14b5c38
Remove white spaces
imRishN ca97114
Fix
imRishN adb7a34
Fix tests
imRishN 1c7cf93
Fix spotless check
imRishN 0bc3ea7
Fix integ tests
imRishN 577c77c
Fix spotless check
imRishN 738a99b
Resolve terminal status during update
imRishN 5dae896
Add java doc
imRishN 97a506a
Fix spotless check
imRishN e227c0b
Resolve PR comments
imRishN ecfdffd
fixes
imRishN 023a048
Fix spotless check
imRishN 703821c
Merge remote-tracking branch 'upstream/main' into decommission/init-m…
imRishN f3e2c57
Empty-Commit
imRishN 948a28d
Merge remote-tracking branch 'upstream/main' into decommission/init-m…
imRishN 0a8e37a
Add UT for helper
imRishN 87bf89c
Fix spotless check
imRishN 4d46a29
Add UT for decommission helper
imRishN a159da6
Merge remote-tracking branch 'upstream/main' into decommission/init-m…
imRishN 6ce6628
Update timeout
imRishN 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
81 changes: 81 additions & 0 deletions
81
.../java/org/opensearch/action/admin/cluster/configuration/VotingConfigExclusionsHelper.java
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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.action.admin.cluster.configuration; | ||
|
||
import org.opensearch.cluster.ClusterState; | ||
import org.opensearch.cluster.coordination.CoordinationMetadata; | ||
import org.opensearch.cluster.coordination.CoordinationMetadata.VotingConfigExclusion; | ||
import org.opensearch.cluster.metadata.Metadata; | ||
|
||
import java.util.Set; | ||
|
||
import static org.opensearch.action.admin.cluster.configuration.TransportAddVotingConfigExclusionsAction.MAXIMUM_VOTING_CONFIG_EXCLUSIONS_SETTING; | ||
|
||
/** | ||
* Static helper utilities for voting config exclusions cluster state updates | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public class VotingConfigExclusionsHelper { | ||
|
||
/** | ||
* Static helper to update current state with given resolved exclusions | ||
* | ||
* @param currentState current cluster state | ||
* @param resolvedExclusions resolved exclusions from the request | ||
* @param finalMaxVotingConfigExclusions max exclusions that be added | ||
* @return newly formed cluster state | ||
*/ | ||
public static ClusterState addExclusionAndGetState( | ||
ClusterState currentState, | ||
Set<VotingConfigExclusion> resolvedExclusions, | ||
int finalMaxVotingConfigExclusions | ||
) { | ||
final CoordinationMetadata.Builder builder = CoordinationMetadata.builder(currentState.coordinationMetadata()); | ||
resolvedExclusions.forEach(builder::addVotingConfigExclusion); | ||
final Metadata newMetadata = Metadata.builder(currentState.metadata()).coordinationMetadata(builder.build()).build(); | ||
final ClusterState newState = ClusterState.builder(currentState).metadata(newMetadata).build(); | ||
assert newState.getVotingConfigExclusions().size() <= finalMaxVotingConfigExclusions; | ||
return newState; | ||
} | ||
|
||
/** | ||
* Resolves the exclusion from the request and throws IAE if no nodes matched or maximum exceeded | ||
* | ||
* @param request AddVotingConfigExclusionsRequest request | ||
* @param state current cluster state | ||
* @param maxVotingConfigExclusions max number of exclusion acceptable | ||
* @return set of VotingConfigExclusion | ||
*/ | ||
public static Set<VotingConfigExclusion> resolveVotingConfigExclusionsAndCheckMaximum( | ||
AddVotingConfigExclusionsRequest request, | ||
ClusterState state, | ||
int maxVotingConfigExclusions | ||
) { | ||
return request.resolveVotingConfigExclusionsAndCheckMaximum( | ||
state, | ||
maxVotingConfigExclusions, | ||
MAXIMUM_VOTING_CONFIG_EXCLUSIONS_SETTING.getKey() | ||
); | ||
} | ||
|
||
/** | ||
* Clears Voting config exclusion from the given cluster state | ||
* | ||
* @param currentState current cluster state | ||
* @return newly formed cluster state after clearing voting config exclusions | ||
*/ | ||
public static ClusterState clearExclusionsAndGetState(ClusterState currentState) { | ||
final CoordinationMetadata newCoordinationMetadata = CoordinationMetadata.builder(currentState.coordinationMetadata()) | ||
.clearVotingConfigExclusions() | ||
.build(); | ||
final Metadata newMetadata = Metadata.builder(currentState.metadata()).coordinationMetadata(newCoordinationMetadata).build(); | ||
return ClusterState.builder(currentState).metadata(newMetadata).build(); | ||
} | ||
} |
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
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.
Lets ensure we call this out in the documentation
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.
Ack