Skip to content

Fix #3014: deletion timestamp handling for clusters with finalizers#3015

Merged
FxKu merged 3 commits into
zalando:masterfrom
thoro:fix-deletion-logic
Jun 1, 2026
Merged

Fix #3014: deletion timestamp handling for clusters with finalizers#3015
FxKu merged 3 commits into
zalando:masterfrom
thoro:fix-deletion-logic

Conversation

@thoro
Copy link
Copy Markdown
Contributor

@thoro thoro commented Dec 14, 2025

When a Postgres cluster has a finalizer, deleting it sets a DeletionTimestamp but doesn't remove the object until the finalizer is cleared. The operator was not properly handling these DeletionTimestamp changes:

  1. postgresqlUpdate() was filtering out events where only DeletionTimestamp changed (it only checked Spec and Annotations), causing the delete to never be processed.

  2. EventUpdate case in processEvent() didn't check for DeletionTimestamp, so even if the event reached the processor, it would run Update() instead of Delete().

  3. removeFinalizer() used a cached object with stale resourceVersion, causing "object has been modified" errors.

Fixes:

  • Add explicit DeletionTimestamp check in postgresqlUpdate() to queue the event
  • Add DeletionTimestamp check in EventUpdate to call Delete() when set
  • Fetch latest object from API before removing finalizer to avoid conflicts

When a Postgres cluster has a finalizer, deleting it sets a DeletionTimestamp
but doesn't remove the object until the finalizer is cleared. The operator
was not properly handling these DeletionTimestamp changes:

1. postgresqlUpdate() was filtering out events where only DeletionTimestamp
   changed (it only checked Spec and Annotations), causing the delete to
   never be processed.

2. EventUpdate case in processEvent() didn't check for DeletionTimestamp,
   so even if the event reached the processor, it would run Update() instead
   of Delete().

3. removeFinalizer() used a cached object with stale resourceVersion,
   causing "object has been modified" errors.

Fixes:
- Add explicit DeletionTimestamp check in postgresqlUpdate() to queue the event
- Add DeletionTimestamp check in EventUpdate to call Delete() when set
- Fetch latest object from API before removing finalizer to avoid conflicts
@zalando-robot
Copy link
Copy Markdown

Cannot start a pipeline due to:

No accountable user for this pipeline: no Zalando employee associated to this GitHub username

Click on pipeline status check Details link below for more information.

@FxKu
Copy link
Copy Markdown
Member

FxKu commented Jun 1, 2026

👍

@FxKu FxKu moved this from Waiting for review to Good state for merge in Postgres Operator Jun 1, 2026
@jopadi
Copy link
Copy Markdown
Member

jopadi commented Jun 1, 2026

👍

@FxKu FxKu merged commit f988e4c into zalando:master Jun 1, 2026
6 checks passed
@github-project-automation github-project-automation Bot moved this from Good state for merge to Done in Postgres Operator Jun 1, 2026
@FxKu
Copy link
Copy Markdown
Member

FxKu commented Jun 1, 2026

Thanks @thoro for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants