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

kube-proxy: remove port opener #108496

Merged
merged 2 commits into from
Mar 16, 2022

Conversation

khenidak
Copy link
Contributor

@khenidak khenidak commented Mar 3, 2022

What type of PR is this?

/kind bug
/kind cleanup

What this PR does / why we need it:

kube-proxy holds service node ports open (Listen() without Read()/Receive() pump). The original idea was to stop users from mistakenly create a listener on the node that listens to a node port which would have created debugging problems. It is important to note that if the opener failed we just log and keep going. However port-opener introduced more problems than value. The problems can be be briefly described as the following:

  1. We open the port before we commit the forwarding/LB rules, the rules typically take much longer to process before committing. That means if the user connected before rules were set they will indeed connect to kube-proxy not the actual pod backing the service. This usually require restarting the client (be it pod or external proce) or the proxy itself. This is more visible as more nodes get introduced to existing clusters with large number of service (the time between open-port and fwd/lb rules is longer).
  2. Port opener also leaves many dangling tcp connections due to this behavior as described here: Nodeport led to many CLOSE_WAIT TCP connections by using kube-proxy iptables mode. #106713

further discussions can be found here: #100643

a script or a stand alone tool can be built (runs on node) to scan services+node-ports and performs a bind(2) on address for debugging purposes. But the scan loop will not be part of kube-proxy.

Which issue(s) this PR fixes:

Fixes #
#100643
#106713

Special notes for your reviewer:

N/A

Does this PR introduce a user-facing change?

kube-proxy will no longer hold service node ports open on the node. Users are still advised not to run any listener on node ports range used by kube-proxy. 

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

N/A 

/sig network

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. sig/network Categorizes an issue or PR as relevant to SIG Network. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. 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. and removed do-not-merge/needs-kind Indicates a PR lacks a `kind/foo` label and requires one. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Mar 3, 2022
@k8s-ci-robot
Copy link
Contributor

@khenidak: This issue is currently awaiting triage.

If a SIG or subproject determines 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.

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 needs-priority Indicates a PR lacks a `priority/foo` label and requires one. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Mar 3, 2022
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. area/ipvs and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 3, 2022
@khenidak khenidak changed the title WIP kube-proxy: remove port opener kube-proxy: remove port opener Mar 3, 2022
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 3, 2022
@khenidak
Copy link
Contributor Author

khenidak commented Mar 3, 2022

fyi @aojea @thockin

@aojea
Copy link
Member

aojea commented Mar 4, 2022

Kubernetes e2e suite: [sig-network] Conntrack should be able to preserve UDP traffic when server pod cycles for a NodePort service expand_more

/test pull-kubernetes-e2e-gci-gce-ipvs

@khenidak
Copy link
Contributor Author

khenidak commented Mar 4, 2022

Kubernetes e2e suite: [sig-network] Conntrack should be able to preserve UDP traffic when server pod cycles for a NodePort service expand_more

/test pull-kubernetes-e2e-gci-gce-ipvs

other than this (it is a mistake, i will fix) https://github.com/kubernetes/kubernetes/pull/108496/files#diff-1f2043db3a45960023376d03e4dd43762d1382ad7ea94e3f26c956410b749c97L1455 i didn't remove anything that interacts with conntrack.

@aojea
Copy link
Member

aojea commented Mar 4, 2022

Kubernetes e2e suite: [sig-network] Conntrack should be able to preserve UDP traffic when server pod cycles for a NodePort service expand_more

/test pull-kubernetes-e2e-gci-gce-ipvs

other than this (it is a mistake, i will fix) https://github.com/kubernetes/kubernetes/pull/108496/files#diff-1f2043db3a45960023376d03e4dd43762d1382ad7ea94e3f26c956410b749c97L1455 i didn't remove anything that interacts with conntrack.

/hold
/test pull-kubernetes-e2e-gci-gce-ipvs

it seems it only fails in this PR 🤔 , we have to be sure

https://prow.k8s.io/job-history/gs/kubernetes-jenkins/pr-logs/directory/pull-kubernetes-e2e-gci-gce-ipvs

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 4, 2022
@thockin
Copy link
Member

thockin commented Mar 14, 2022

Oh, I see Kal beat me to it :)

Copy link
Member

@thockin thockin left a comment

Choose a reason for hiding this comment

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

Good riddance to bad rubbish!

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: khenidak, thockin

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

@aojea
Copy link
Member

aojea commented Mar 15, 2022

@danwinship is ok to unhold or do you still have concerns?

@aojea
Copy link
Member

aojea commented Mar 15, 2022

I don't see anybody disagrees with removing them, that doesn't mean that we should not explore new options to protect users I will put on hold for some time in case I got it wrong and there are opposition to remove them, or just unhold it if we all agree on removing it

/lgtm /hold

/hold cancel

let's use silence as no disagreement

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 15, 2022
@k8s-triage-robot
Copy link

The Kubernetes project has merge-blocking tests that are currently too flaky to consistently pass.

This bot retests PRs for certain kubernetes repos according to the following rules:

  • The PR does have any do-not-merge/* labels
  • The PR does not have the needs-ok-to-test label
  • The PR is mergeable (does not have a needs-rebase label)
  • The PR is approved (has cncf-cla: yes, lgtm, approved labels)
  • The PR is failing tests required for merge

You can:

/retest

@aojea
Copy link
Member

aojea commented Mar 16, 2022

/retest

@k8s-ci-robot k8s-ci-robot merged commit 7152825 into kubernetes:master Mar 16, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.24 milestone Mar 16, 2022
@danwinship
Copy link
Contributor

It's already possible in that case - kube-proxy will log that :22 was in use, but then it will go ahead and capture the port anyway!

image

k8s-ci-robot added a commit that referenced this pull request Apr 28, 2022
…496-upstream-release-1.22

Automated cherry pick of #108496: iptables: remove port opener
k8s-ci-robot added a commit that referenced this pull request Apr 28, 2022
…496-upstream-release-1.23

Automated cherry pick of #108496: iptables: remove port opener
k8s-ci-robot added a commit that referenced this pull request Apr 28, 2022
…496-upstream-release-1.21

Automated cherry pick of #108496: iptables: remove port opener
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. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. 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/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

6 participants