Repository navigation
fix(controller): set observedGeneration on the Cluster Ready condition - #11560
GellertBabel wants to merge 10 commits into
Conversation
|
❗ By default, the pull request is configured to backport to all release branches.
|
armru
left a comment
There was a problem hiding this comment.
Thanks for working on this! As I see it, though, this doesn't quite fix the issue.
SetClusterReadyCondition runs inside PatchWithOptimisticLock, which re-fetches the Cluster, so cluster.Generation is the generation at patch time, not the one the reconciliation evaluated. We re-fetch the Cluster several times during a reconciliation, and the generation can go up in the meantime. In that case we'd mark Ready=True for a generation that hasn't been reconciled yet, and whose reconciliation could still fail.
8f68a2a to
e9650af
Compare
|
/test |
|
@leonardoce, here's the link to the E2E on CNPG workflow run: https://github.com/cloudnative-pg/cloudnative-pg/actions/runs/38908931929 |
|
/test |
|
@armru, here's the link to the E2E on CNPG workflow run: https://github.com/cloudnative-pg/cloudnative-pg/actions/runs/39452131994 |
|
/test |
|
@leonardoce, here's the link to the E2E on CNPG workflow run: https://github.com/cloudnative-pg/cloudnative-pg/actions/runs/39792991288 |
kubectl wait --for=condition=Ready could succeed on a Ready=True value from a stale generation, since the condition never set observedGeneration. Populate it in SetClusterReadyCondition and SetAdmissionError. Closes cloudnative-pg#11390 Signed-off-by: Gellért Bábel <[email protected]>
Signed-off-by: Leonardo Cecchi <[email protected]>
A status write in the middle of the reconciliation loop reloads the Cluster, so the Ready condition could report a generation the loop never reconciled. Record the generation at the start of Reconcile and use it as observedGeneration. The instance manager no longer sets the Ready condition after an in-place primary restart: it only moves the phase back to Healthy and leaves Ready to the operator, which knows the generation it has reconciled. Signed-off-by: Gellért Bábel <[email protected]>
…p evaluated A status patch can decode a newer spec into the Cluster mid-loop, so the loop may reach a healthy phase partly thanks to a generation other than the reconciled one it stamps. RegisterPhase now leaves the Ready condition untouched when it registers a healthy phase for a Cluster whose generation no longer matches the reconciled one: the next loop, triggered by the generation change, marks it as ready. The instance manager sets the Ready condition again after an in-place primary restart, as it did before. Signed-off-by: Armando Ruocco <[email protected]>
While the primary restarts in-place the operator pauses its reconciliation, so a spec change made in the meantime is not applied. The instance manager then marked the Cluster ready for the generation it read, letting a wait on the Ready condition return before the operator reconciled that generation. The instance manager and the restart command of the kubectl plugin now keep the generation of the current Ready condition, the last one the operator reconciled. Signed-off-by: Armando Ruocco <[email protected]>
5524324 to
f9d8c2e
Compare
kubectl wait --for=condition=Ready could succeed on a Ready=True value from a stale generation, since the condition never set observedGeneration. Populate it in SetClusterReadyCondition and SetAdmissionError.
Closes #11390