Skip to content

Give UDP connections a chance to close gracefully#60074

Closed
jsravn wants to merge 1 commit intokubernetes:masterfrom
jsravn:improve-udp-endpoint-handling
Closed

Give UDP connections a chance to close gracefully#60074
jsravn wants to merge 1 commit intokubernetes:masterfrom
jsravn:improve-udp-endpoint-handling

Conversation

@jsravn
Copy link
Copy Markdown
Contributor

@jsravn jsravn commented Feb 20, 2018

What this PR does / why we need it:

Delay UDP connection tracking flush on endpoint removal.

This gives termination grace period a chance to work, such as when
kube-dns is restarted or redeployed.

Otherwise in-flight requests will always time out whenever an endpoint
removal occurs.

We get DNS timeouts occasionally when kube-dns redeploys. I believe the immediate UDP flush is what causes it.

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

Special notes for your reviewer:

Release note:

Delay UDP connection flush to give connections a chance to gracefully terminate.

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. 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 Feb 20, 2018
@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. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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 Feb 20, 2018
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 21, 2018
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: jsravn
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: thockin

Assign the PR to them by writing /assign @thockin in a comment when ready.

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

The pull request process is described 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

@jsravn
Copy link
Copy Markdown
Contributor Author

jsravn commented Feb 21, 2018

I'll be testing this out in our dev clusters to see if it helps w/ DNS timeouts.

@krmayankk
Copy link
Copy Markdown

@jsravn could we delay the udp connection flush by some other param like terminationGracePeriodSeconds rather than hard coding it ? May be some users want that, immediate flush ?

@jsravn
Copy link
Copy Markdown
Contributor Author

jsravn commented Feb 22, 2018

@krmayankk I added it as a flag to kube-proxy so it's configurable - setting to 0 disables, same as prior behavior. It is also similar to TCP connections in netfilter, they have a single timeout.

I did think about using terminationGracePeriodSeconds as described in the linked issue. The problem is kube-proxy only knows about endpoints - and terminationGracePeriodSeconds is a pod field. It's doable but would require an API change probably - adding a new field to endpoint that is filled in by the endpoints controller. I think this is a good idea actually, just a bit more work and API change (which I'm not that familiar with doing).

@jsravn
Copy link
Copy Markdown
Contributor Author

jsravn commented Feb 22, 2018

Using terminationGracePeriod also makes sense for the IPVS proxier (#57841).

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 26, 2018
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 looks like it'll fail because of this

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.

You need to pass epSvcPair to the goroutine. See this for why.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@jsravn jsravn force-pushed the improve-udp-endpoint-handling branch from 4ac9734 to 5ac386c Compare February 28, 2018 10:42
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 28, 2018
Delay UDP connection tracking flush on endpoint removal.

This gives termination grace period a chance to work, such as when
kube-dns is restarted or redeployed.

Otherwise in-flight requests will always time out whenever an endpoint
removal occurs.
@jsravn jsravn force-pushed the improve-udp-endpoint-handling branch from 5ac386c to 369acae Compare February 28, 2018 10:44
@bburket
Copy link
Copy Markdown

bburket commented Mar 1, 2018

@jsravn how did your testing go? We are facing some cantankerous issues with DNS timeouts in our cluster

@jsravn
Copy link
Copy Markdown
Contributor Author

jsravn commented Mar 1, 2018

@bburket Not great I'm afraid. I still am getting dns errors on restarts, with this change cherry picked to 1.8. Either my cherry pick is broken or there is something else going on I don't quite understand yet.

@BenTheElder
Copy link
Copy Markdown
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Mar 2, 2018
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

k8s-ci-robot commented Mar 2, 2018

@jsravn: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
pull-kubernetes-bazel-test 369acae link /test pull-kubernetes-bazel-test

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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/test-infra repository. I understand the commands that are listed here.

@tcolgate
Copy link
Copy Markdown

We are seeing similar issues with kube-dns on cluster-autoscaler downscales. NodeJS seems to have particular pathological behaviour on DNS timeouts, so this is causing us some considerable pain.

@jsravn
Copy link
Copy Markdown
Contributor Author

jsravn commented Apr 17, 2018

Sorry I got pulled off on other work, so haven't had time to work on this further.

@m1093782566
Copy link
Copy Markdown
Contributor

/assign

Probably IPVS side needs a similar change.

@fejta-bot
Copy link
Copy Markdown

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 4, 2018
@BenTheElder
Copy link
Copy Markdown
Member

@m1093782566 seems like we probably still want this...?
/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 4, 2018
@m1093782566
Copy link
Copy Markdown
Contributor

@BenTheElder

Thanks but I would prefer #66012 which is up-to-date and fix both TCP and UDP issues.

@BenTheElder
Copy link
Copy Markdown
Member

It looks like #66012 only contains IPVS changes though, while this one has iptables?

@m1093782566
Copy link
Copy Markdown
Contributor

oops, seems you are right. This PR covers iptables while #66012 covers IPVS - they do the different thing.

@m1093782566
Copy link
Copy Markdown
Contributor

xref: #71514

@fejta-bot
Copy link
Copy Markdown

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 27, 2019
@jsravn
Copy link
Copy Markdown
Contributor Author

jsravn commented Mar 1, 2019

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 1, 2019
@fejta-bot
Copy link
Copy Markdown

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 30, 2019
@jsravn
Copy link
Copy Markdown
Contributor Author

jsravn commented May 31, 2019

Going to close this - as a lot of behavior currently relies on the UDP connections being dropped immediately. IPVS proxier has also done the same recently.

@jsravn jsravn closed this May 31, 2019
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. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

9 participants