Repository navigation
feat(database): skip finalizer for resources with databaseReclaimPolicy retain - #10620
GellertBabel wants to merge 1 commit into
Conversation
…cy retain Fixes cloudnative-pg#10535 Database, Publication and Subscription resources with a retain reclaim policy no longer receive a finalizer. This prevents the resource from getting stuck with a deletionTimestamp when the operator or operand is unavailable, which would block namespace deletion. Signed-off-by: Gellért Bábel <[email protected]>
|
❗ By default, the pull request is configured to backport to all release branches.
|
|
Thanks for working on this. Before getting into the implementation details, let me check my understanding of the scenario, because I have a concern with the approach — correct me if I'm getting something wrong. If I understand it correctly, the hang described in #10535 only occurs when the operator runs in the same namespace as the cluster. In the standard topology, with the operator in its own namespace, deleting the operand namespace should not get stuck today: as soon as the Cluster is deleted, the operator itself removes the finalizers from every Database, Publication and Subscription belonging to it (notifyDeletionToOwnedResources, internal/controller/finalizers_delete.go), even when the instance pods are already gone. If that's right, the fix would only benefit the shared-namespace topology, while the behavior change applies to every deployment. My worry is what the other deployments would lose: the deletion-time evaluation of the reclaim policy. Today the finalizer is present from the first reconciliation, so switching a resource from retain to delete and deleting it right afterwards still guarantees the drop — the instance manager re-reads the policy while processing the deletion. With this change, a resource created under retain (which is the default) carries no finalizer, so a flip to delete followed by a quick deletion could skip the drop entirely, and the database would silently survive in PostgreSQL despite an explicit delete request. If my reading is correct, I'd rather scope the mitigation to the shared-namespace topology, or make it an explicit opt-in, than change the default semantics globally. But I may be missing a case where the current finalizer hurts outside that topology — happy to be corrected. I'd also like the other maintainers to weigh in on this one before we move forward. |
|
A user should wait for observedGeneration to equal generation before deleting. Even today I wouldn't assume it's safe to delete the CR right away, a reclaim-policy change is a spec change, and it only takes effect once reconciled. Yes, the problem is more important for the shared-namespace use case, and I'm fine limiting the code to that. That said, it can still happen in a separate-namespace setup. When multiple namespaces are deleted at the same time, or the operator simply isn't running at that moment, the finalizers never get removed and the namespace hangs. Not adding the finalizer at all when not needed. Makes for a safer but less feature-rich operator, which is the tradeoff the users hitting this actually want. |
Fixes #10535
Database, Publication and Subscription resources with a retain reclaim policy no longer receive a finalizer. This prevents the resource from getting stuck with a deletionTimestamp when the operator or operand is unavailable, which would block namespace deletion.