Ability to trigger auto rebalance on imbalance feature - #13037
Ability to trigger auto rebalance on imbalance feature #13037ShubhamRwt wants to merge 10 commits into
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
@ShubhamRwt can we get a green build before starting for an early review please? Failure are around the CruiseControlReconciler so maybe something to fix in the logic before taking a look. Thanks :-) |
|
@ppatierno All the tests seems to be passing now |
ppatierno
left a comment
There was a problem hiding this comment.
@ShubhamRwt I had a first quick pass but it needs more detailed review.
dcb35bc to
6ce0247
Compare
Signed-off-by: ShubhamRwt <shubhamrwt02@gmail.com>
Signed-off-by: ShubhamRwt <shubhamrwt02@gmail.com>
Signed-off-by: ShubhamRwt <shubhamrwt02@gmail.com>
Signed-off-by: ShubhamRwt <shubhamrwt02@gmail.com>
Signed-off-by: ShubhamRwt <shubhamrwt02@gmail.com>
Signed-off-by: ShubhamRwt <shubhamrwt02@gmail.com>
Signed-off-by: ShubhamRwt <shubhamrwt02@gmail.com>
49588ed to
39afd8d
Compare
8c5ceb9 to
c8b11b5
Compare
Signed-off-by: ShubhamRwt <shubhamrwt02@gmail.com>
8b2a441 to
3ac94ed
Compare
|
This PR is now ready for review |
| }); | ||
| } else { | ||
| LOGGER.infoCr(reconciliation, "Rebalancing completed, transitioning to Idle"); | ||
| return updateRebalanceCompletionTime() |
There was a problem hiding this comment.
we are updating the rebalance completion time when the rebalancing completed but how does it relate with the proposal where at some point we said:
The ConfigMap's lastRebalanceCompletionTime now reflects the failure timestamp
So it looks like the timestamp should be updated when there is a failure too?
| * @return CompletionStage with GoalViolationInfo if violations detected, null otherwise | ||
| */ | ||
| public CompletionStage<GoalViolationInfo> checkForGoalViolations() { | ||
| if (kafkaCr.getSpec() == null || kafkaCr.getSpec().getCruiseControl() == null) { |
There was a problem hiding this comment.
why are we checking the CC is configured, I would assume this code at this deep level won't be never reached if CC is not configured. I mean, why I should check for goal violations if CC is not even configured?
|
|
||
| if (imbalanceConfig.isEmpty()) { | ||
| return CompletableFuture.completedFuture(null); | ||
| } |
There was a problem hiding this comment.
The same applies to the above checks, why should I check for goal violation if auto-rebalance is not configured? Should this being called only when we are sure CC is enabled in the Kafka CR? Maybe a check would be needed somewhere in a upper level within the code?
| return supplier.secretOperations.getAsync(reconciliation.namespace(), CruiseControlResources.secretName(reconciliation.name())) | ||
| .thenCompose(ccSecret -> { | ||
| if (ccSecret == null) { | ||
| LOGGER.warnCr(reconciliation, "Cruise Control secret not found, skipping anomaly detection"); |
There was a problem hiding this comment.
The log is misleading, we are not skipping anomaly detection. We tried to detect anomalies but it failed because for some reason the CC Secret is not available. I would more use:
Cruise Control secret not found, goal violations cannot be detected
| } | ||
|
|
||
| return supplier.secretOperations.getAsync(reconciliation.namespace(), CruiseControlResources.apiSecretName(reconciliation.name())) | ||
| .thenCompose(ccApiSecret -> { |
There was a problem hiding this comment.
We checked for ccSecret to be null before but we are not doing the same here for ccApiSecret, why?
| - DiskCapacityGoal | ||
| - DiskUsageDistributionGoal | ||
| skipHardGoalCheck: true | ||
| ---- |
There was a problem hiding this comment.
you should take a look on this approved proposal https://github.com/strimzi/proposals/blob/main/154-kafkarebalance-custom-resource-consolidation.md that should be land at some point.
If it comes first, we need to update the examples with the new KafkaRebalance API.
|
|
||
| The operator tracks rebalance completion times in a ConfigMap named `<cluster_name>-auto-rebalance-imbalance-tracker`. | ||
| This prevents the operator from retriggering rebalances for anomalies that were already addressed by a previous rebalance. | ||
| The ConfigMap is automatically managed by the operator and deleted when the Kafka cluster is deleted. |
There was a problem hiding this comment.
maybe an example of the ConfigMap structure would be useful.
|
|
||
| == Failure recovery | ||
|
|
||
| If an auto-rebalance fails (the `KafkaRebalance` transitions to `NotReady`), the operator transitions back to `Idle` and deletes the failed resource. |
There was a problem hiding this comment.
the operator transitions back to
Idle
What is transitioning to Idle? The operator itself doesn't have Idle state. What are you referring to?
|
|
||
| If an auto-rebalance fails (the `KafkaRebalance` transitions to `NotReady`), the operator transitions back to `Idle` and deletes the failed resource. | ||
| The operator does not immediately retry. | ||
| If the underlying issue persists, Cruise Control detects the goal violation again in the next anomaly detection cycle and a fresh rebalance is triggered. |
There was a problem hiding this comment.
It's related to what I already mention about the detection interval in CC. It's different from the reconciliation period. This sentence let the user thinks that a new rebalance triggers when CC detect an anomaly while it's not true. It triggers when the operator ask to CC for anomaly on the next reconciliation.
| If the underlying issue persists, Cruise Control detects the goal violation again in the next anomaly detection cycle and a fresh rebalance is triggered. | ||
|
|
||
| If the operator crashes while in `RebalanceOnImbalance` state, on restart it resumes monitoring from the current state. | ||
| If the `KafkaRebalance` resource is missing (for example, deleted while the operator was not running), the operator transitions to `Idle` and relies on Cruise Control's next anomaly detection cycle to retrigger if violations persist. |
There was a problem hiding this comment.
Still this ...
operator transitions to
Idle
Type of change
Description
This PR implements the proposal auto-rebalance-on-imbalance. This feature allows the operator to trigger rebalance automatically in case their are some imbalance in the cluster
Checklist
Please go through this checklist and make sure all applicable tasks have been done