Skip to content

[Bug]: cnpg destroy race condition: pod deleted before PVCs allows operator to recreate pod #10846

Description

@daanvinken

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

[email protected]

Version

1.28 (latest patch)

What version of Kubernetes are you using?

1.33

What is your Kubernetes environment?

Other

How did you install the operator?

Helm

What happened?

What happened

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

  1. Cordon a node running a CNPG replica (node-local storage like OpenEBS)
  2. Delete the replica pod so it goes Pending (PVC bound to cordoned node)
  3. Run kubectl cnpg destroy <cluster> <instance>
  4. Observe: operator recreates the pod before PVCs are deleted
  5. 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

Activity

  1. added
    triage
    on Jun 8, 2026
  2. added
    bug 🐛
    and removed on Jun 21, 2026
  3. added this to the 1.30.1 milestone on Jul 20, 2026
  4. added 3 commits that reference this issue on Aug 12, 2026
    c0e61d4
    45a7380
    4c7eaf6
  5. added a commit that references this issue on Aug 12, 2026
    791af39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug 🐛triage

Type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions