Repository navigation
fix(chi): gate aborted auto-recovery on operator ready label - #2108
Tyagiquamar wants to merge 6 commits into
Conversation
Re-enqueue aborted CHIs when the clickhouse.altinity.com/ready label transitions to yes, not on kubelet container readiness alone. Fixes Altinity#2106
PR #2108 — Code ReviewPR: #2108 Verdict: Changes requested The PR changes two files and attempts to fix issue #2106 by triggering recovery when the operator's There are two significant issues with this approach. Finding 1 — [P1] The new trigger can prevent recovery indefinitelyFile: pkg/controller/chi/worker-pod-retry.go The PR replaces the Pod NotReady → Ready trigger with an operator-label if !isPodOperatorReadyLabelNotReadyToReadyTransition(oldPod, newPod, cr) {
return
}This creates a circular dependency. The operator normally sets the label to Consider the exact failure described in issue #2106:
Unless another event initiates reconciliation, the CHI can remain Aborted and replica 0-1 can remain excluded indefinitely. This is supported by the existing call chain:
Required change: Do not make automatic recovery depend exclusively on a label that recovery itself must restore. Finding 2 — [P1] The original Service-outage risk remainsFile: pkg/controller/chi/worker-status-helpers.go PR #2108 changes only the recovery trigger. It does not change how the reconciler decides whether another replica is safe to 8000 rely on.
That predicate is used by:
Therefore, if a reconcile is triggered by a CHI update or another event, the original sequence can still occur:
The safety check can incorrectly count 0-1 as a healthy peer, authorize exclusion of 0-0, and leave the Service without eligible replicas. Required change: Ensure the peer-safety and recovery-ordering decisions account for A dedicated Service-eligibility predicate may be preferable to changing every use of Tests need to cover the actual failureThe new unit tests correctly exercise the label-transition helper, but they encode the problematic behavior: {"kubelet ready but label still no", pod(false), pod(true), false},That is exactly the event that needs to initiate recovery in issue #2106. PR #2108 — Code ReviewPR: #2108 Verdict: Changes requested The PR changes two files and attempts to fix issue #2106 by triggering recovery when the operator's I found two significant issues with this approach. Finding 1 — [P1] The new trigger can prevent recovery indefinitelyFile: pkg/controller/chi/worker-pod-retry.go The PR replaces the Pod NotReady → Ready trigger with an operator-label if !isPodOperatorReadyLabelNotReadyToReadyTransition(oldPod, newPod, cr) {
return
}This creates a circular dependency. The operator normally sets the label to Consider the exact failure described in issue #2106:
Unless another event initiates reconciliation, the CHI can remain Aborted and replica 0-1 can remain excluded indefinitely. This is supported by the existing call chain:
Required change: Do not make automatic recovery depend exclusively on a label that recovery itself must restore. Finding 2 — [P1] The original Service-outage risk remainsFile: pkg/controller/chi/worker-status-helpers.go PR #2108 changes only the recovery trigger. It does not change how the reconciler decides whether another replica is safe to rely on.
That predicate is used by:
Therefore, if a reconcile is triggered by a CHI update or another event, the original sequence can still occur:
The safety check can incorrectly count 0-1 as a healthy peer, authorize exclusion of 0-0, and leave the Service without eligible replicas. Required change: Ensure the peer-safety and recovery-ordering decisions account for A dedicated Service-eligibility predicate may be preferable to changing every use of Tests need to cover the actual failureThe new unit tests correctly exercise the label-transition helper, but they encode the problematic behavior: {"kubelet ready but label still no", pod(false), pod(true), false},That is exactly the event that needs to initiate recovery in issue #2106. I would request a regression test with one shard and two replicas, asserting that:
CI statusAt the time of review:
|
|
Addressed the review feedback on
Local check: |
Restore kubelet NotReady->Ready as the aborted auto-recovery trigger so recovery is not gated on a label that recovery itself restores. Count only clickhouse.altinity.com/ready=yes hosts as healthy peers for recovery ordering and disruption safety.
|
✘ [ Fail ] /regression/e2e.test_operator/test_010044. Schema and data propagation with slow replica (25m 14s) Without the PR, once the slow replica is Kubernetes Ready, hasUnhealthyHosts() can become false. For a same-generation recovery event, the operator then returns gateNothingToDo and skips reconciliation. With the PR, the missing Service-ready label keeps hasUnhealthyHosts() true, so that early exit no longer applies. Recommended correctionFor test_010044, explicitly disable automatic recovery in its operator configuration (test-044-chopconf.yaml) That preserves the original test's sequence: abort, wait for the Pod, verify schema is absent, force reconciliation, and verify schema appears. |
The slow replica stays Service-ineligible after it becomes Ready, so recovery would reconcile before the test checks that the schema is absent. Co-authored-by: Cursor <cursoragent@cursor.com>
Summary
clickhouse.altinity.com/readylabel transitions toyes, instead of on kubelet container readiness alone.Test plan
go test ./pkg/controller/chi -run 'TestIsPodOperatorReadyLabelNotReadyToReadyTransition|TestShouldTriggerAutoRecovery'(not run locally; CI-first A1)gh pr checkson this PRFixes #2106