Skip to content

Add deletionTimestamp check to avoid race condition#982

Open
wpross wants to merge 2 commits intokubernetes:masterfrom
wpross:fix-981
Open

Add deletionTimestamp check to avoid race condition#982
wpross wants to merge 2 commits intokubernetes:masterfrom
wpross:fix-981

Conversation

@wpross
Copy link
Copy Markdown

@wpross wpross commented Feb 27, 2026

This PR is to fix Issue 981.

It makes sure to check the deletionTimestamp to not sync in case the service is to be deleted in nodeSyncService.
In needsCleanup it checks the deletionTimestamp before checking for the finalizer to make sure the right path (not the else) is taken.

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla bot commented Feb 27, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Feb 27, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

This issue is currently awaiting triage.

If the repository mantainers determine this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Welcome @wpross!

It looks like this is your first PR to kubernetes/cloud-provider-gcp 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/cloud-provider-gcp has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Feb 27, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Hi @wpross. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Feb 27, 2026
@k8s-ci-robot k8s-ci-robot added the sig/network Categorizes an issue or PR as relevant to SIG Network. label Feb 27, 2026
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Feb 27, 2026
@bowei
Copy link
Copy Markdown
Member

bowei commented Feb 27, 2026

Please add a unit test for this fix.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 2, 2026
@wpross
Copy link
Copy Markdown
Author

wpross commented Mar 2, 2026

Please add a unit test for this fix.

done.

@hdp617
Copy link
Copy Markdown
Contributor

hdp617 commented Mar 13, 2026

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 13, 2026
@hdp617
Copy link
Copy Markdown
Contributor

hdp617 commented Mar 18, 2026

@wpross Thanks for looking into this! We removed Bazel recently so this PR might needs to be updated.

/assign @YifeiZhuang

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 2, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: wpross
Once this PR has been reviewed and has the lgtm label, please ask for approval from yifeizhuang. For more information see the Code Review Process.

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

Details 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

@YifeiZhuang
Copy link
Copy Markdown
Contributor

/assign @mmamczur @FelipeYepez

return true
}

if !servicehelper.HasLBFinalizer(service) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is forked from here https://github.com/kubernetes/cloud-provider/blob/master/controllers/service/controller.go#L364
And it was on purpose. The service deletion is delayed and waits for all finalizers to be removed before actually deleting the object.

What are the side effect, e.g. resource leakage did you see other than the error messages.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for pointing it out @YifeiZhuang

so yes, this code was forked and is used only if the service has a specific LB class set. For usual services (no loadBalancerClass) which I believe the fix is intended for, you need to change the code in https://github.com/kubernetes/cloud-provider/ and vendor it in here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. sig/network Categorizes an issue or PR as relevant to SIG Network. 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.

Service controller tries to add finalizer to service being deleted, causing errors

7 participants