-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Add validation of the number_of_shards parameter in Shrink Action of ILM #74219
Merged
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
977ab67
Add validation of the number_of_shards parameter in Shrink Action of ILM
609d402
Merge remote-tracking branch 'origin/master' into enhance_shrink
1f7c94c
Use a single step
e7bc201
Merge remote-tracking branch 'origin/master' into enhance_shrink
4644f45
add more checks and fix test failure
e41b71d
Merge remote-tracking branch 'origin/master' into enhance_shrink
6e810f4
Merge remote-tracking branch 'origin/master' into enhance_shrink
cfa6827
Merge remote-tracking branch 'upstream/enhance_shrink' into enhance_s…
ee9b060
fix test failure
3f50349
Merge remote-tracking branch 'origin/master' into enhance_shrink
4d3400e
fix test failure
c67d7e0
Merge remote-tracking branch 'origin/master' into enhance_shrink
68bec26
Merge remote-tracking branch 'origin/master' into enhance_shrink
a4a5064
add new test
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,18 +45,37 @@ public class SetSingleNodeAllocateStep extends AsyncActionStep { | |
private static final Logger logger = LogManager.getLogger(SetSingleNodeAllocateStep.class); | ||
public static final String NAME = "set-single-node-allocation"; | ||
|
||
public SetSingleNodeAllocateStep(StepKey key, StepKey nextStepKey, Client client) { | ||
private Integer numberOfShards; | ||
|
||
public SetSingleNodeAllocateStep(StepKey key, StepKey nextStepKey, Client client, Integer numberOfShards) { | ||
super(key, nextStepKey, client); | ||
this.numberOfShards = numberOfShards; | ||
} | ||
|
||
@Override | ||
public boolean isRetryable() { | ||
return true; | ||
} | ||
|
||
public Integer getNumberOfShards() { | ||
return numberOfShards; | ||
} | ||
|
||
@Override | ||
public void performAction(IndexMetadata indexMetadata, ClusterState clusterState, | ||
ClusterStateObserver observer, ActionListener<Boolean> listener) { | ||
String indexName = indexMetadata.getIndex().getName(); | ||
if (numberOfShards != null) { | ||
int sourceNumberOfShards = indexMetadata.getNumberOfShards(); | ||
int factor = sourceNumberOfShards / numberOfShards; | ||
if (factor * numberOfShards < sourceNumberOfShards) { | ||
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. Just curious, is there any particular reason you didn't go with 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. Just a habit, |
||
logger.debug("the number of shards [" + sourceNumberOfShards + "] of the source index [" + indexName + | ||
"] must be a multiple of [" + numberOfShards + "]"); | ||
listener.onFailure(new IllegalArgumentException("the number of shards [" + sourceNumberOfShards + | ||
"] of the source index [" + indexName + "] must be a multiple of [" + numberOfShards + "]")); | ||
return; | ||
} | ||
} | ||
// These allocation deciders were chosen because these are the conditions that can prevent | ||
// allocation long-term, and that we can inspect in advance. Most other allocation deciders | ||
// will either only delay relocation (e.g. ThrottlingAllocationDecider), or don't work very | ||
|
@@ -72,7 +91,6 @@ public void performAction(IndexMetadata indexMetadata, ClusterState clusterState | |
RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, routingNodes, clusterState, null, | ||
null, System.nanoTime()); | ||
List<String> validNodeIds = new ArrayList<>(); | ||
String indexName = indexMetadata.getIndex().getName(); | ||
final Map<ShardId, List<ShardRouting>> routingsByShardId = clusterState.getRoutingTable() | ||
.allShards(indexName) | ||
.stream() | ||
|
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
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.
What do you think about refactoring all of this into some new
Step
? I like the logic overall, and I agree that we should do the validation before the single allocation starts, I'm just not sure it belongs within this step.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.
Yeah, it's a good idea, I will refactor the code soon.
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.
hi @joegallo , I've refactor the code yet, can you take a look at the new commit?