zalando / zalando/postgres-operator
Operator skips cluster update when changing controller ID
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 5.2k
- Forks
- 1.1k
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 3
Description
- Which image of the operator are you using? ghcr.io/zalando/postgres-operator:v2.0.1
- Where do you run it? Azure Kubernetes Service
- Are you running Postgres Operator in production? yes
- Type of issue? Bug report
Hello,
I'm currently experimenting with running two instances of Postgres Operator. After changing a cluster's controller ID, I've noticed that the Postgres Operator does not update the cluster immediately.
Description
When changing the acid.zalan.do/controller annotation on a Postgres cluster manifest, the corresponding Postgres Operator should update the cluster accordingly. However, the update is skipped and the cluster is updated during the next resync.
Reason
The postgresqlUpdate method checks both the previous and the current manifests using postgresqlCheck.
As the previous manifest's annotation doesn't match the operator's controller ID, the check fails and the update is skipped.
Suggested fix
I think the postgresqlCheck method should ignore ownership when checking the previous manifest.
I think postgresqlUpdate should enqueue an EventSync when the previous manifest's check fails (we cannot use EventUpdate here because the K8s objects may or may have been created by the other Postgres Operator, which may or may not exist).
Note: I realize we may run into a race condition because we don't know for sure that the other Postgres Operator is done with the cluster (waiting for the resync does not prevent the race condition, though it is less likely). So maybe the appropriate response should be "don't change theacid.zalan.do/controller annotation"?
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 in pkg/controller/postgresql.go at postgresqlUpdate and postgresqlCheck, then trace the EventSync path. Reproduce the controller-ID annotation change and verify that the cluster is processed immediately rather than at the next resync, while considering the stated ownership and race-condition concern.
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
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100