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

🐛 all: only set finalizers if deletionTimestamp is not set #8949

Merged

Conversation

sbueringer
Copy link
Member

Signed-off-by: Stefan Büringer buringerst@vmware.com

What this PR does / why we need it:
As reported in #8946 Cluster API today tries to add a finalizer even if objects already has a deletionTimestamp set.

This results in the following error message from the APIserver:

"Reconciler error" err="Cluster.cluster.x-k8s.io "sgcluster" is invalid: metadata.finalizers: Forbidden: no new finalizers can be added if the object is being deleted, found new finalizers []string{"cluster.cluster.x-k8s.io"}"

This case especially occurs if a finalizer of another controller is removed after our finalizer.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Related to #8946

Signed-off-by: Stefan Büringer buringerst@vmware.com
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 3, 2023
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 3, 2023
@sbueringer sbueringer changed the title all: only set finalizers if deletionTimestamp is not set 🐛 all: only set finalizers if deletionTimestamp is not set Jul 3, 2023
@sbueringer
Copy link
Member Author

/test pull-cluster-api-e2e-full-main

@sbueringer
Copy link
Member Author

sbueringer commented Jul 3, 2023

cc @enxebre given somewhat related discussion last week around Machine finalizer

@enxebre
Copy link
Member

enxebre commented Jul 3, 2023

Make sense to me. Alternatively we could move up reconcile deletion logic to run before Add finalizer logic

@sbueringer
Copy link
Member Author

Make sense to me. Alternatively we could move up reconcile deletion logic to run before Add finalizer logic

I think moving the finalizer down or the reconcileDelete up is in most cases the same change :)

Copy link
Contributor

@killianmuldoon killianmuldoon left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 3, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 68d5b76224ea18a74178743f2525b1b02dec0dfa

@enxebre
Copy link
Member

enxebre commented Jul 3, 2023

/lgtm
Deferring to @fabriziopandini final tag to ack his concerns are adressed

Copy link
Member

@fabriziopandini fabriziopandini left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fabriziopandini

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 3, 2023
@k8s-ci-robot k8s-ci-robot merged commit 730f63d into kubernetes-sigs:main Jul 3, 2023
13 of 14 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.5 milestone Jul 3, 2023
@sbueringer sbueringer deleted the pr-optimize-add-finalizer branch July 3, 2023 17:51
@killianmuldoon
Copy link
Contributor

/area api

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/api Issues or PRs related to the APIs cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants