Skip to content

neonvm-controller: Improve usage of finalizer methods #1379

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

Merged
merged 3 commits into from
Jun 16, 2025

Conversation

sharnoff
Copy link
Member

controllerutil.AddFinalizer/RemoveFinalizer are made to be idempotent, and return whether or not any changes were made. We can use that in our logic around adding / removing finalizers to simplify things.

This encompasses two small changes:

  1. Don't check ContainsFinalizer before adding — just try to add it, and persist the update if it was actually changed.
  2. If RemoveFinalizer doesn't change the object, treat this as an unexpected error!

controllerutil.AddFinalizer/RemoveFinalizer are made to be idempotent,
and return whether or not any changes were made. We can use that in our
logic around adding / removing finalizers to simplify things.

This encompasses two small changes:

1. Don't check `ContainsFinalizer` before adding - just try to add it,
   and persist the update if it was actually changed.
2. If `RemoveFinalizer` doesn't change the object, treat this as an
   unexpected error!
@Omrigan Omrigan assigned sharnoff and unassigned Omrigan Jun 15, 2025
@sharnoff sharnoff merged commit 6113eb5 into main Jun 16, 2025
35 checks passed
@sharnoff sharnoff deleted the sharnoff/neonvm-controller-finalizer branch June 16, 2025 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants