Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #98 from keyallis/issue-1887
Browse files Browse the repository at this point in the history
clear finalizers on watched delete event (#1887)
  • Loading branch information
Oscar Ward committed Aug 1, 2023
2 parents 6807d93 + 127208a commit 5fdf278
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/watcher/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,17 @@ func doWatch[T client.Object](ctx context.Context, revision string, watchFunc wa
case watch.Deleted:
o := event.Object.DeepCopyObject()
mo := o.(client.Object)
changed := false
if mo.GetDeletionTimestamp().IsZero() {
now := metav1.Now()
mo.SetDeletionTimestamp(&now)
changed = true
}
if len(mo.GetFinalizers()) > 0 {
mo.SetFinalizers(nil)
changed = true
}
if changed {
event.Object = mo
}
fallthrough
Expand Down

0 comments on commit 5fdf278

Please sign in to comment.