Repository navigation
Description
Is there an existing issue already for this bug?
- I have searched for an existing issue, and could not find anything. I believe this is a new bug.
I have read the troubleshooting guide
- I have read the troubleshooting guide and I think this is a new bug.
I am running a supported version of CloudNativePG
- I have read the troubleshooting guide and I think this is a new bug.
Contact Details
No response
Version
1.30.0
What version of Kubernetes are you using?
1.36
What is your Kubernetes environment?
Self-managed: kind (evaluation)
How did you install the operator?
YAML manifest
What happened?
If I change a Cluster spec and then check readiness, I can get Ready=True that was produced before my change was ever looked at. There is nothing in Cluster.status that lets me tell the difference, so kubectl wait --for=condition=Ready returns success on a stale condition.
I ran into this in CI. We upscale Clusters and then assert the resulting replica counts. The assertion races the operator and fails intermittently, more often the more Clusters we have.
The minimal case is three commands against a healthy single-instance Cluster:
$ kubectl get cluster db -o jsonpath='{.status.phase}{" gen="}{.metadata.generation}'
Cluster in healthy state gen=1
$ kubectl patch cluster db --type=merge -p '{"spec":{"instances":3}}'
cluster.postgresql.cnpg.io/db patched
$ kubectl wait --for=condition=Ready cluster/db --timeout=30s
cluster.postgresql.cnpg.io/db condition met # returns immediately
At that point metadata.generation is 2, but conditions[Ready].lastTransitionTime still holds its pre-change value and only one instance pod exists.
Operator with an idle queue, measuring from the operator's own log timestamps between serving the update webhook and calling RegisterPhase(PhaseUpgrade):
run webhook admit rollout registered delta
1 21:04:13.110614 21:04:13.235556 124.9 ms
2 21:04:39.317498 21:04:39.436688 119.2 ms
3 21:05:05.481548 21:05:05.608910 127.4 ms
The observedGeneration that is in the schema, inherited from metav1.Condition, is never populated. SetClusterReadyCondition builds the condition with only Type, Status, Reason and Message (pkg/resources/status/transactions.go:34), so it stays 0.
What I expected
Ready to mean what the troubleshooting guide says it means, or failing that, some way to tell that the status I am reading corresponds to the spec I applied. The usual one is status.observedGeneration, so that generation == observedGeneration plus Ready=True means the change is done.
The other CRDs in the group already do this. Database, DatabaseRole, Publication and Subscription all set Status.ObservedGeneration = .Generation (api/v1/database_funcs.go:43, databaserole_funcs.go:37, publication_funcs.go:43, subscription_funcs.go:43). Cluster is the only one without it.
Cluster resource
Relevant log output
Code of Conduct
- I agree to follow this project's Code of Conduct
Activity
dosubot commentedon Sep 1, 2026
@GellertBabel, your root-cause analysis checks out against
main. Here's a summary of what the code shows:SetClusterReadyConditionconstructs theReadycondition with onlyType,Status,Reason, andMessage— it never setsObservedGeneration[1]. Every path that updates theReadycondition goes through this helper:RegisterPhase(which is the main reconciler path), the admission-error guard inSetAdmissionError, and the plugin/promote/restart CLI paths. None of them populateObservedGenerationeither.ClusterStatushas nostatus.observedGenerationfield [2], unlikeDatabaseStatusand the other declarative-object CRDs which each carry an explicitObservedGeneration int64set viaSetAsReady()/HasReconciliations().The
observedGenerationfield does exist in the CRD schema for each condition entry — it's inherited from the standardmetav1.Conditiontype [3] — but because the Go code never writes it,meta.SetStatusConditionleaves it at0.So
kubectl wait --for=condition=Readycan return immediately on a staleReady=Truefrom a previous generation, exactly as you described. There is no field inCluster.statusthat distinguishes "Ready reflects the current generation" from "Ready was set before your patch was reconciled."I didn't find an existing issue or in-flight PR targeting this gap. A fix mirroring the
Database-style approach — either populatingcondition.ObservedGenerationinsideSetClusterReadyCondition, and/or adding a top-levelStatus.ObservedGenerationfield toClusterStatusset alongsideRegisterPhase— would close it and match the pattern already used elsewhere in the API group.To reply, just mention @dosu.
Share context across your team and agents. Try Dosu.
fix(controller): set observedGeneration on the Cluster Ready condition
github-actions commentedon Nov 22, 2026
This issue is stale because it has been open for 60 days with no activity.