Skip to content

fix ipvs_svc deletion #80942

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 1 commit into from
Aug 13, 2019
Merged

Conversation

gongguan
Copy link
Contributor

@gongguan gongguan commented Aug 3, 2019

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind api-change
/kind bug
/kind cleanup
/kind design
/kind documentation
/kind failing-test
/kind feature
/kind flake

What this PR does / why we need it:
In ipvs mode, when service deleted but rs(pod) exist, related ipvs rule and address bound in ipvs0 will not be deleted.
I think it's unreasonable that kubernetes-service deleted but the service ip is available(ipvs rule not deleted). When you create same service again, new virtual service(totally two ipvs virtual service) will proxy to the same rs, too. And the deleted service ip will exist on both ipvs rule and ipvs0 device.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Fix a bug in the IPVS proxier where virtual servers are not cleaned up even though the corresponding Service object was deleted.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Aug 3, 2019
@k8s-ci-robot
Copy link
Contributor

Hi @gongguan. 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.

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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 3, 2019
@gongguan
Copy link
Contributor Author

gongguan commented Aug 3, 2019

/kind bug

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. and removed needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Aug 3, 2019
@gongguan
Copy link
Contributor Author

gongguan commented Aug 3, 2019

/sig network
/area ipvs

@k8s-ci-robot k8s-ci-robot added area/ipvs sig/network Categorizes an issue or PR as relevant to SIG Network. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Aug 3, 2019
@gongguan
Copy link
Contributor Author

gongguan commented Aug 3, 2019

another question:
graceful termination can be deleted too?
As service deleted, can ipvs virtual server be deleted directly, then unbind svc addr in dev ipvs0

@gongguan
Copy link
Contributor Author

gongguan commented Aug 3, 2019

there is a logical error in current code:
graceful termination will never executed

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Aug 3, 2019
@gongguan
Copy link
Contributor Author

gongguan commented Aug 4, 2019

/assign @andrewsykim
/cc @lbernail @m1093782566

@andrewsykim
Copy link
Member

/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. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 5, 2019
@andrewsykim
Copy link
Member

/priority important-soon

@andrewsykim
Copy link
Member

I also expected a service deletion to trigger a deletion of the matching endpoint resource which should trigger graceful termination. I

It does, but for TCP it takes 15m for those endpoints to be gracefully terminated and so the virtual server doesn't delete for 15m as well. So I think either we delete the virtual server right away (this PR) or we decrease the graceful termination timeout to a lower value.

@lbernail
Copy link
Contributor

lbernail commented Aug 12, 2019

@andrewsykim in the test I did, gracefultermination was not triggered at all (and weight remains at 1) so I suspect something is wrong in the handler

Anyway, if we agree we can remove services without gracefultermination this is not important

The PR looks good. @gongguan can you add a test for this specific scenario? (by fixing the test in TestCleanLegacyService)

@lbernail
Copy link
Contributor

@andrewsykim OK I think I know what happens: syncProxyRules is called for service deletion and endpoint deletion, but the reconcile loop only considers active services: https://github.com/kubernetes/kubernetes/blob/master/pkg/proxy/ipvs/proxier.go#L902

So the only way to trigger gracefulTermination for real servers on service deletion would be in cleanLegacyService

@andrewsykim
Copy link
Member

andrewsykim commented Aug 12, 2019

Thanks for clarifying @lbernail!

Anyway, if we agree we can remove services without gracefultermination this is not important

IMO if a Service is deleted there's no reason to try graceful termination. I will ask some folks in SIG Network though to confirm if this shouldn't be the case.

The PR looks good. @gongguan can you add a test for this specific scenario?

Added a test case for this here #81309, PTAL :)

/lgtm

Thanks @gongguan!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 12, 2019
@lbernail
Copy link
Contributor

Thanks for adding the test!
We'll need to backport this to all supported branches

@lbernail
Copy link
Contributor

I just remember the context behind the graceful termination behavior: #71894
TL;DR we did not have expirenodestconn before which means when we removed a VS (and therefore RS) on service deletion, established connections were not terminated and their traffic was being blackholed.

Because we now set expirenodestconn, established connections will be terminated as soon as a packet is sent

@andrewsykim
Copy link
Member

/retest

@gongguan
Copy link
Contributor Author

gongguan commented Aug 13, 2019

Added a test case for this here #81309, PTAL :)

Thanks for @andrewsykim 's test. By the way, what else need to be done for me?

@andrewsykim
Copy link
Member

Not much from here, PR should be merged by the bot shortly :). Thanks @gongguan!

@k8s-ci-robot k8s-ci-robot merged commit 12a085f into kubernetes:master Aug 13, 2019
@k8s-ci-robot k8s-ci-robot added this to the v1.16 milestone Aug 13, 2019
k8s-ci-robot added a commit that referenced this pull request Aug 20, 2019
…80942-origin-release-1.15

Automated cherry pick of #80942: Fix a bug in the IPVS proxier where virtual servers are not
k8s-ci-robot added a commit that referenced this pull request Aug 20, 2019
…80942-origin-release-1.14

Automated cherry pick of #80942: Fix a bug in the IPVS proxier where virtual servers are not
k8s-ci-robot added a commit that referenced this pull request Aug 20, 2019
…80942-origin-release-1.13

Automated cherry pick of #80942: Fix a bug in the IPVS proxier where virtual servers are not
@gongguan gongguan deleted the fix_ipvs_svc_del branch December 3, 2019 11:27
@JokerDevops
Copy link

So how do I make sure this problem is solved now? In which version did the solution arrive?

@JokerDevops
Copy link

@Davidrjx
Copy link

part of issues still exists, address bound in kube-ipvs0 will not be deleted in kubernetes1.18.0

@willzhang
Copy link

SAME IN kubernetes1.23.5

@andrewsykim
Copy link
Member

Please open a new issue with the details included and assign it to me and @uablrek

@uablrek
Copy link
Contributor

uablrek commented Apr 14, 2022

I can't reproduce this in v1.23.5. I tried;

  • Connect via tcp to a ClusterIP and let the connection stay open
  • watch ip addr show dev kube-ipvs0 in another terminal
  • kubectl delete svc-name

The ClusterIP is removed from kube-ipvs0 almost immediately. The tcp connection is black-holed.

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/ipvs cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/network Categorizes an issue or PR as relevant to SIG Network. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants