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

Improve finalizer handling #2039

Closed
sbueringer opened this issue Jul 19, 2023 · 5 comments · Fixed by #2099
Closed

Improve finalizer handling #2039

sbueringer opened this issue Jul 19, 2023 · 5 comments · Fixed by #2099
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. kind/release-blocking Issues or PRs that need to be closed before the next CAPV release lifecycle/active Indicates that an issue or PR is actively being worked on by a contributor.

Comments

@sbueringer
Copy link
Member

sbueringer commented Jul 19, 2023

/kind bug

I think we have to improve our finalizer handling in CAPV.

The ideal behavior in Reconcile is the following:

  • if deletionTimestamp is set
    • => do nothing
  • if deletionTimestamp is unset
    • if finalizer is set
      • => do nothing
    • if finalizer is unset
      • => set finalizer and immediately requeue

I recently had a PR to fix this everywhere in core CAPI: kubernetes-sigs/cluster-api#8949

Reasoning:

  • if we don't immediately requeue we potentially create resources in vSphere that would be orphaned if the same resource is deleted before we can set the finalizer in defer
  • if we try to set the finalizer when the deletionTimestamp is already set we just get an error from the apiserver because this operation is not allowed

An easy example how this should look like can be found here: https://github.com/sbueringer/cluster-api/blob/cef1cf1d9312088a785c520f49970b1c609ab9ad/internal/controllers/cluster/cluster_controller.go#L145-L158

Note: it's important that the defer patch is done in a way that the finalizer is actually written

Environment:

  • Cluster-api-provider-vsphere version:
  • Kubernetes version: (use kubectl version):
  • OS (e.g. from /etc/os-release):
@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Jul 19, 2023
@sbueringer
Copy link
Member Author

cc @yastij @srm09 @randomvariable

@chrischdi @killianmuldoon Would be great if one of you can pick this up. I think we should implement this until the v1.8.0 release and also consider cherry-picking it back.

@sbueringer
Copy link
Member Author

/kind release-blocking

@k8s-ci-robot k8s-ci-robot added the kind/release-blocking Issues or PRs that need to be closed before the next CAPV release label Jul 20, 2023
@zhanggbj
Copy link
Contributor

If this is still available, I would like to work on it :)
/assign

@randomvariable
Copy link
Member

If you start work on it, use a
/lifecycle active to show you're actively working on it.

@zhanggbj
Copy link
Contributor

Thanks @randomvariable for the kind reminder :)
/lifecycle active

@k8s-ci-robot k8s-ci-robot added the lifecycle/active Indicates that an issue or PR is actively being worked on by a contributor. label Jul 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. kind/release-blocking Issues or PRs that need to be closed before the next CAPV release lifecycle/active Indicates that an issue or PR is actively being worked on by a contributor.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants