zalando / zalando/postgres-operator
controllerrevision not cleaned up after Postgresql deletion
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 5.2k
- Forks
- 1.1k
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 3
Description
Please, answer some short questions which should help us to understand your problem / question better?
- Which image of the operator are you using?
ghcr.io/zalando/postgres-operator:v1.14.0 - Where do you run it - cloud or metal? Kubernetes or OpenShift? [AWS K8s | GCP ... | Bare Metal K8s]
K8s - Are you running Postgres Operator in production? [yes | no]
yes - Type of issue? [Bug report, question, feature request, etc.]
Bug report
Hi,
I’m running the Zalando Postgres Operator in cluster-wide mode, and overall the resource cleanup during Postgresql instance deletion works well. However, I’ve observed that controllerrevision resources are left behind after deleting a Postgresql CR - even though other resources like StatefulSets, Pods, Services, and Secrets are properly removed.
My operator configuration includes enable_owner_references: true:
configKubernetes:
pod_management_policy: "parallel"
enable_persistent_volume_claim_deletion: true
enable_finalizers: false
enable_owner_references: true
enable_pod_antiaffinity: false
cluster_domain: "cluster.local"
...
Upon inspecting the controllerrevision resource before deletion, it correctly has an ownerReference pointing to the corresponding StatefulSet. However, after the Postgresql CR is deleted and the StatefulSet is removed, the controllerrevision remains - and its ownerReference is gone.
This suggests that the controllerrevision becomes orphaned during the deletion process. I suspect this might be due to the use of metav1.DeletePropagationOrphan when deleting the StatefulSet.
Would switching to DeletePropagationForeground be more appropriate here to allow Kubernetes to garbage collect the controllerrevision via its ownership chain?
Thanks in advance for looking into this!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the StatefulSet deletion logic in pkg/cluster/cluster.go around line 112 and pkg/cluster/resources.go around line 250, focusing on DeletePropagationOrphan and the controllerrevision ownerReference. Reproduce deletion of a Postgresql CR and verify that the controllerrevision is removed after the StatefulSet, with its ownership chain preserved until Kubernetes garbage collection completes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, kubernetes, postgresql
- Domain
- databases, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100