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

Add support for nf_conntrack_tcp_be_liberal sysctl to kube-proxy #120354

Merged
merged 1 commit into from Oct 31, 2023

Conversation

aroradaman
Copy link
Member

@aroradaman aroradaman commented Sep 1, 2023

What type of PR is this?

/kind feature

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #94861

Special notes for your reviewer:

Does this PR introduce a user-facing change?

kube-proxy: Added an option/flag for configuring the `nf_conntrack_tcp_be_liberal` sysctl (in the kernel's netfilter conntrack subsystem).  When enabled, kube-proxy will not install the DROP rule for invalid conntrack states, which currently breaks users of asymmetric routing.

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


@k8s-ci-robot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@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. kind/feature Categorizes issue or PR as related to a new feature. size/L Denotes a PR that changes 100-499 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. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Sep 1, 2023
@aroradaman
Copy link
Member Author

/test all

@k8s-ci-robot k8s-ci-robot added area/code-generation area/kube-proxy kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/network Categorizes an issue or PR as relevant to SIG Network. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Sep 1, 2023
@aojea
Copy link
Member

aojea commented Sep 1, 2023

The open issue talks about parity with the existing TCP options #120214

We expressed several times that kube-proxy should not be too invasive with the node parameters, why do we add nf_conntrack_tcp_be_liberal here?
Bear in mind we can be stepping into some other component setting this values already

/assign @danwinship @khenidak

As you commented on the referenced issue

@danwinship
Copy link
Contributor

I said we shouldn't set it by default. I forgot we already had infra for letting the admin configure conntrack-related sysctls. That's fine.

@aroradaman aroradaman marked this pull request as ready for review September 5, 2023 13:41
@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 Sep 5, 2023
@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. labels Oct 26, 2023
@danwinship
Copy link
Contributor

@danwinship should I handle this case (almost hypothetical ) - user sets tcp-be-liberal true in config and false in command line flag.

It should behave the same way other flags behave... I think the current expectation is that the command line flags are completely overridden by the config file if you pass --config. (But I'm not even sure about that and it's kind of a mess.)

@aroradaman
Copy link
Member Author

aroradaman commented Oct 27, 2023

It should behave the same way other flags behave... I think the current expectation is that the command line flags are completely overridden by the config file if you pass --config. (But I'm not even sure about that and it's kind of a mess.)

Yes, if --config is passed command line flags are completely overridden (except hostname).

#120354 (comment), here you suggested to manually sync command line flag with config, does this still hold ?

I added the logic to give precedence to command line flag over config for this option, the same way we do for hostname. LMK, will remove this logic.

// processHostnameOverrideFlag processes hostname-override flag
func (o *Options) processHostnameOverrideFlag() error {
// Check if hostname-override flag is set and use value since configFile always overrides
if len(o.hostnameOverride) > 0 {
hostName := strings.TrimSpace(o.hostnameOverride)
if len(hostName) == 0 {
return fmt.Errorf("empty hostname-override is invalid")
}
o.config.HostnameOverride = strings.ToLower(hostName)
}
return nil
}

@danwinship
Copy link
Contributor

oh, sorry, I meant "sync" as in "make sure that the right one overrides the other one". If the command-line flag reads directly into a field in o.config then the overriding happens automatically (because reading the config file overwrites the values set by the FlagSet) but if the command-line flag reads into a special field in the Options then you have do a bit of extra work. Which, I guess is just checking whether o.ConfigFile is set or not, and only copying the flag value into o.config if it wasn't.

But anyway, we only needed the cliflags.TriState if we want to be able to specify both "clear the flag" and "don't change the value of the flag". But since we only care about the latter, we can use a bool where true means set it and false means don't change it, and then you can just read directly into the o.config and let the normal overriding mechanism handle it.

Signed-off-by: Daman Arora <aroradaman@gmail.com>
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Oct 27, 2023
@danwinship
Copy link
Contributor

/retitle Add support for `nf_conntrack_tcp_be_liberal_ sysctl to kube-proxy
/lgtm
/approve
/assign @thockin
for API approval

The release note should be updated to reference #94861 and mention that this you can now work around that problem by specifying this option, which will cause kube-proxy to not create the DROP rule that breaks asymmetric routing.

Oh, also, the "Fixes" part of the initial comment is wrong now since the UDP stuff got split out, but it should say this fixes 94861.

@k8s-ci-robot k8s-ci-robot changed the title Adding more conntrack sysctls to kube proxy Add support for `nf_conntrack_tcp_be_liberal_ sysctl to kube-proxy Oct 28, 2023
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 28, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 3e6390648bd8b2fa8c94e33b3a35c77b142658fd

@aroradaman aroradaman changed the title Add support for `nf_conntrack_tcp_be_liberal_ sysctl to kube-proxy Add support for nf_conntrack_tcp_be_liberal sysctl to kube-proxy Oct 28, 2023
@aojea
Copy link
Member

aojea commented Oct 29, 2023

/lgtm

@aroradaman
Copy link
Member Author

ping @thockin

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.

Thanks!

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aroradaman, danwinship, 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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 31, 2023
@k8s-ci-robot k8s-ci-robot merged commit 5d03ce7 into kubernetes:master Oct 31, 2023
14 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.29 milestone Oct 31, 2023
@leilajal
Copy link
Contributor

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Oct 31, 2023
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/code-generation area/kube-proxy cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/feature Categorizes issue or PR as related to a new feature. 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. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. 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. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kube-proxy: Drop packets in INVALID state drops packets from outside the pod range
10 participants