Rebalancing Fix : Handle All Nodes Disabled Case #121
Open
Conversation
| if (idealState.getRebalanceMode() == IdealState.RebalanceMode.FULL_AUTO && !idealState | ||
| .getReplicas().equals("0")) { | ||
| Map<String, List<String>> preferenceLists = idealState.getPreferenceLists(); | ||
| if (preferenceLists == null || preferenceLists.isEmpty()) { |
Collaborator
There was a problem hiding this comment.
When will the preference list be null?
Collaborator
There was a problem hiding this comment.
Could this end up in a situation where rebalancer could fail to calculate preference list due to some other issue and we end up dropping all partitions which could be a risky behaviour?
| } | ||
| // Some but not all lists empty: this is valid when maxPartitionsPerInstance limits capacity. | ||
| // Only reject when maxPartitionsPerInstance is NOT set and we have inconsistent empty lists. | ||
| if (emptyListCount > 0 && idealState.getMaxPartitionsPerInstance() > 0) { |
Collaborator
There was a problem hiding this comment.
Confirm the default value for getMaxPartitionsPerInstance once.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Issues
Description
SCENARIO
Observation (Without Fix)
Reason:
BEFORE

AFTER
- Added hasCurrentStateForResource() helper method
- Allows empty preference lists when existing replicas need cleanup (all nodes disabled)
- Distinguishes between "not initialized" (reject) vs "all disabled" (allow for cleanup)
- Test case for all nodes disabled with current state (should allow)
- Test case for uninitialized resource (should reject)
Code Changes:
i. All lists empty + current state exists → Allow (all nodes disabled cleanup)
ii. Some lists empty + maxPartitionsPerInstance set → Allow (capacity-limited)
iii. Some lists empty + no maxPartitionsPerInstance → Reject (inconsistent state)
Tests