Skip to content

fix(controller): recover owned resource cleanup for deleted clusters - #11229

Merged
litaocdl merged 1 commit into
cloudnative-pg:dev/fix-orphan-finalizer-stripfrom
GabriFedi97:review/fix-orphan-finalizer-strip
Jul 21, 2026
Merged

litaocdl merged 1 commit into
cloudnative-pg:dev/fix-orphan-finalizer-stripfrom
GabriFedi97:review/fix-orphan-finalizer-strip

Conversation

@GabriFedi97

@GabriFedi97 GabriFedi97 commented Jul 20, 2026 •

Copy link
Copy Markdown
Member

The owned-resource watches that re-run notifyDeletionToOwnedResources after a restart only fired for resources already carrying a deletionTimestamp. Because the Cluster has no finalizer, deleting only the Cluster (rather than the whole namespace) leaves the Database, Publication, Subscription and DatabaseRole objects without a deletionTimestamp of their own. On restart their initial cache-sync events were dropped by the predicate, the Cluster was already gone so nothing else enqueued a reconcile, and the finalizers were never stripped.

Admit the initial-list create events so the cleanup runs on restart regardless of whether the owned resource is itself being deleted;

Also watch DatabaseRole,
whose finalizer is likewise managed by the instance manager and carries the same orphan risk.

Refs #10535

@GabriFedi97
GabriFedi97 force-pushed the review/fix-orphan-finalizer-strip branch 2 times, most recently from 826e0aa to 453ad58 Compare July 20, 2026 14:48
@GabriFedi97
GabriFedi97 marked this pull request as ready for review July 20, 2026 14:50
@GabriFedi97
GabriFedi97 requested a review from a team July 20, 2026 14:50
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. bug 🐛 Something isn't working release-1.28 release-1.29 release-1.30 labels Jul 20, 2026
The owned-resource watches that re-run notifyDeletionToOwnedResources
after a restart only fired for resources already carrying a
deletionTimestamp. Because the Cluster has no finalizer, deleting only
the Cluster (rather than the whole namespace) leaves the Database,
Publication and Subscription objects without a deletionTimestamp of
their own. On restart their initial cache-sync events were dropped by
the predicate, the Cluster was already gone so nothing else enqueued a
reconcile, and the finalizers were never stripped.

Admit the initial-list create events so the cleanup runs on restart
regardless of whether the owned resource is itself being deleted;

Also watch DatabaseRole,
whose finalizer is likewise managed by the instance manager and carries
the same orphan risk.

Assisted-by: Claude Opus 4.8
Signed-off-by: Gabriele Fedi <[email protected]>
@GabriFedi97
GabriFedi97 force-pushed the review/fix-orphan-finalizer-strip branch from 453ad58 to f8ba34c Compare July 21, 2026 07:58
@litaocdl
litaocdl merged this pull request into cloudnative-pg:dev/fix-orphan-finalizer-strip Jul 21, 2026
5 checks passed
mnencia pushed a commit that referenced this pull request Jul 22, 2026
…11229)

The owned-resource watches that re-run `notifyDeletionToOwnedResources`
after a restart only fired for resources already carrying a
deletionTimestamp. Because the Cluster has no finalizer, deleting only
the Cluster (rather than the whole namespace) leaves the `Database`,
`Publication`, `Subscription` and `DatabaseRole` objects without a
deletionTimestamp of their own. On restart their initial cache-sync
events were dropped by the predicate, the Cluster was already gone so
nothing else enqueued a reconcile, and the finalizers were never
stripped.

Admit the initial-list create events so the cleanup runs on restart
regardless of whether the owned resource is itself being deleted;

Also watch DatabaseRole,
whose finalizer is likewise managed by the instance manager and carries
the same orphan risk.

Refs #10535

Signed-off-by: Gabriele Fedi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🐛 Something isn't working release-1.28 release-1.30 size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants