HDDS-15535. Container Balancer should validate configuration and report startup failures to user - #10812
Conversation
…rt startup failures to user
|
Open question for reviewers: |
a9449c5 to
c205795
Compare
|
@ashishkumar50 could you please review this PR. |
ashishkumar50
left a comment
There was a problem hiding this comment.
@sreejasahithi Thanks for the patch, please find comments inline.
| "Container Balancer requires at least 2 eligible datanodes but only " | ||
| + "%d is available.", eligibleCount)); | ||
| } | ||
| int maxDatanodesToInvolve = (int) (conf.getMaxDatanodesRatioToInvolvePerIteration() * eligibleCount); |
There was a problem hiding this comment.
(int)(0.20×eligibleCount)≥2==>0.20×eligibleCount≥2==>eligibleCount≥10
So a cluster with 6 healthy in-service datanodes passes Check 1 (6 ≥ 2) but fails Check 2, because (int)(0.20 × 6) = 1 < 2.
Any cluster with fewer than 10 eligible datanodes will fail in Check 2 and fails to start, even though it has well more than 2 nodes.
If at least 2 nodes are available we should allow balancer to start and it should work.
There was a problem hiding this comment.
The behavior when these checks are removed at startup. With 6 eligible datanodes and the default 20%, (int)(0.20 × 6) = 1, so maxDatanodesToInvolve = 1.
The balancer still starts, but in ContainerBalancerTask.doIteration() the first call to adaptWhenNearingIterationLimits() fires immediately (count=0, 0+1==1), which calls resetPotentialTargets(selectedTargets) with an empty set. That clears all potential targets before any source/target pairing happens so no moves are scheduled. The iteration ends with CAN_NOT_BALANCE_ANY_MORE and the balancer stops with "No more eligible container moves were found".
Since balancing requires at least one source and one target (2 datanodes), a cap of 1 makes balancing impossible under the configured limit. Rejecting this at startup with an explicit config error is better than starting and immediately stopping.
For clusters with fewer than 10 eligible datanodes, the user needs to raise --max-datanodes-percentage-to-involve-per-iteration. the percentage is a hard cap, and if the cap is below the minimum needed for a source/target pair the config is invalid for that cluster size.
There was a problem hiding this comment.
Yes in this case it makes sense to stop at the start.
But in large cluster when after some iteration of balancing if eligible nodes comes down to below 10, balancer should keep running(I think this should be already working?).
There was a problem hiding this comment.
No, if eligible datanodes drop below 10 at 20%, the balancer stops on the next iteration with CAN_NOT_BALANCE_ANY_MORE. That is pre existing behaviour in ContainerBalancerTask.
There was a problem hiding this comment.
Correction on my earlier comment, I mixed eligible datanodes (total healthy in-service pool) with unbalanced nodes. In a large cluster unbalanced nodes dropping below 10 does not stop the balancer as the 20% cap is still computed against the full pool.
|
sarvekshayr
left a comment
There was a problem hiding this comment.
Thanks @sreejasahithi for working on this. I've given minor comments below -
|
@ashishkumar50 and @sarvekshayr I have made the changes requested, could you please review it. |
sarvekshayr
left a comment
There was a problem hiding this comment.
Thanks @sreejasahithi for updating the patch. LGTM.
|
Thanks @sreejasahithi for the patch and @ashishkumar50 for the review. |
What changes were proposed in this pull request?
Currently, Container Balancer could start with configuration that made balancing impossible or misleading, with no clear reporting to the user.
This change adds startup time validation and ensures configuration errors are returned to the client with a useful message.
Problem :
Users could start the balancer with invalid or self-defeating configuration, for example:
This patch adds validation in ContainerBalancer before the balancer task starts. Failures throw InvalidContainerBalancerConfigurationException, so ozone admin containerbalancer start reports the reason to the user.
Note: The datanode check validates that at least two eligible datanodes exist and that the configured percentage allows at least two datanodes to be involved per iteration. It does not validate whether those datanodes can actually form a valid source or target, because that would require reusing much of the balancer iteration logic. Failures of that kind may still appear via ozone admin containerbalancer status (stop reason / message).
What is the link to the Apache JIRA
HDDS-15535
How was this patch tested?
Added tests
Manually tested in docker ozone cluster:
Green CI : https://github.com/sreejasahithi/ozone/actions/runs/29627948987