Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle delete before adding finalizer #1177

Merged
merged 1 commit into from
Jul 31, 2023
Merged

Conversation

darkowlzz
Copy link
Contributor

In Reconcile() methods, move the object deletion above add finalizer. Finalizers can't be set when an object is being deleted.

Found by @hiddeco while working on helm-controller. Refer kubernetes-sigs/cluster-api@cef1cf1 .

@darkowlzz darkowlzz added the enhancement New feature or request label Jul 24, 2023
Copy link
Member

@hiddeco hiddeco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Backporting this change shouldn’t necessarily be required as we do not have multiple reconcilers handling this resource.

It could however become a problem if an arbitrary 3rd party registers a finalizer on the object.

Thanks @darkowlzz 🥇

In Reconcile() methods, move the object deletion above add finalizer.
Finalizers can't be set when an object is being deleted.

Introduce a cacheless client in suite_test to use for testing this
change. It ensures that the Reconcile() call always operates on the
latest version of the object which has the deletion timestamp and
existing finalizer.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
@darkowlzz darkowlzz merged commit 96f6041 into main Jul 31, 2023
10 checks passed
@darkowlzz darkowlzz deleted the delete-before-finalizer branch July 31, 2023 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants