You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: cnpg destroy race condition: pod deleted before PVCs allows operator to recreate pod #10846
kubectl cnpg destroy sometimes requires two invocations to fully clean up an instance. On the first call, the pod is deleted but the operator immediately recreates it (stuck Pending). The second call succeeds because the PVCs are already gone.
Root cause
cnpg destroy deletes the pod first (destroy.go#L49), then fetches and deletes the PVCs (destroy.go#L68, destroy.go#L118). Between those calls, the operator reconciles, sees dangling PVCs (pod gone, PVCs remain), and recreates the pod to reattach them. Then destroy deletes the PVCs, leaving the recreated pod stuck Pending with no PVCs.
The operator's internal delete path (ensureInstanceIsDeleted in cluster_scale.go#L98-L109) does it in the correct order: PVCs first, then pod. The CLI should do the same.
How to reproduce
Cordon a node running a CNPG replica (node-local storage like OpenEBS)
Delete the replica pod so it goes Pending (PVC bound to cordoned node)
Run kubectl cnpg destroy <cluster> <instance>
Observe: operator recreates the pod before PVCs are deleted
Run kubectl cnpg destroy again — succeeds because PVCs are already gone
Environment
CNPG 1.28.2
OpenEBS LVM (node-local storage)
Kubernetes 1.33
Cluster resource
Relevant log output
Code of Conduct
I agree to follow this project's Code of Conduct
Reacted by dosubot, Adam Kafka and Pedro Morello Abbud
Activity
fix: delete PVCs before pods in cnpg destroy (#10847)
fix: delete PVCs before pods in cnpg destroy (#10847)
fix: delete PVCs before pods in cnpg destroy (#10847)
fix: delete PVCs before pods in cnpg destroy (cloudnative-pg#10847)