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

do a better job of validating IP family of kube-proxy config #119003

Merged
merged 5 commits into from
Jul 4, 2023

Conversation

danwinship
Copy link
Contributor

What type of PR is this?

/kind bug
/kind cleanup

What this PR does / why we need it:

spun out of #118408; this centralizes figuring out what mode kube-proxy is running in (single-stack IPv4, single-stack IPv6, dual-stack IPv4-primary or dual-stack IPv6-primary), and then checks that the configuration actually makes sense for that mode.

Alas, we don't want to retroactively make previously-working configurations be broken, so we merely warn rather than erroring out on most errors.

Does this PR introduce a user-facing change?

Kube-proxy will now warn at startup if the configuration seems inconsistent
with respect to IP families. (For example, if you have an IPv4 node IP, but
`--cluster-cidr` is IPv6.)

/sig network
/assign @aojea

@k8s-ci-robot k8s-ci-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Jun 30, 2023
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. 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. sig/network Categorizes an issue or PR as relevant to SIG Network. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jun 30, 2023
@k8s-ci-robot
Copy link
Contributor

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-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 Jun 30, 2023
@k8s-ci-robot k8s-ci-robot requested review from andrewsykim and dcbw June 30, 2023 16:51
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: danwinship

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 approved Indicates a PR has been approved by an approver from all required OWNERS files. area/kube-proxy labels Jun 30, 2023
cmd/kube-proxy/app/server_others.go Outdated Show resolved Hide resolved
cmd/kube-proxy/app/server.go Outdated Show resolved Hide resolved
cmd/kube-proxy/app/server.go Outdated Show resolved Hide resolved
@thockin thockin removed the kind/bug Categorizes issue or PR as related to a bug. label Jun 30, 2023
@thockin
Copy link
Member

thockin commented Jun 30, 2023

LTGM - I would take the localmode tweak as a followup or in here (or argue me down) and if 0.0.0.0 works.

oops, gofmt fail.

@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 Jun 30, 2023
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 30, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 03fc27b9a595d5d8944b853d2b44b0368d50c519

@thockin thockin removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 30, 2023
Rather than having this as part of createProxier(), explicitly figure
out what IP families the proxier can support beforehand, and bail out
if this conflicts with the detected IP family.
errors = append(errors, fmt.Errorf("cluster is %s but ipvs.excludeCIDRs contains only IPv%s addresses", clusterType, badFamily))
}

if badBindAddress(s.Config.HealthzBindAddress, badFamily) {
Copy link
Member

Choose a reason for hiding this comment

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

Does this handle "0.0.0.0:" and ":" correctly? It reads as 4 but accepts on 6, too:

$ cat main.go 
package main

import (
	"fmt"
	"net"
	"os"
)

func main() {
	l, err := net.Listen("tcp", "0.0.0.0:9376")
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	l.Accept()
	fmt.Println("done")
}

$ go run main.go &
[1] 3125929

$ netcat -6 localhost 9376
done

[1]+  Done                    go run main.go

$ go run main.go &
[1] 3126055

$ netcat -4 localhost 9376
done

[1]+  Done                    go run main.go

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry, yes, I addressed that in the update: badBindAddress checks ip.IsUnspecified() now, and considers that acceptable regardless of family; the unit tests check that.

@danwinship
Copy link
Contributor Author

/retest-required

@danwinship danwinship force-pushed the proxy-single-dual branch from 3070ca5 to 37c3cbd Compare July 1, 2023 13:22
@aojea
Copy link
Member

aojea commented Jul 2, 2023

Kubernetes e2e suite: [It] [sig-cli] Kubectl client Simple pod should contain last line of the log expand_less 23s
{ failed [FAILED] Expected
: failed to create fsnotify watcher: too many open files
to contain substring

/test pull-kubernetes-e2e-gce

@danwinship danwinship force-pushed the proxy-single-dual branch from 37c3cbd to a966d18 Compare July 3, 2023 12:34
@aojea
Copy link
Member

aojea commented Jul 3, 2023

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 3, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: a3f6223e2717fa56956a1ea195cfda0608ae7aae

@aojea
Copy link
Member

aojea commented Jul 3, 2023

Kubernetes e2e suite: [It] [sig-network] HostPort validates that there is no conflict between pods with same hostPort but different hostIP and protocol [LinuxOnly] [Conformance] expand_less 54s
{ failed [FAILED] Told to stop trying after 2.032s.
The phase of Pod e2e-host-exec is Failed which is unexpected.
In [It] at: test/e2e/framework/pod/pod_client.go:104 @ 07/03/23 12:56:06.107

🤔 👀
unrelated to this but I start to see some unexpected tests failing with "pod phases" errors

/test pull-kubernetes-conformance-kind-ga-only-parallel

@aojea
Copy link
Member

aojea commented Jul 4, 2023

/hold cancel

@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 Jul 4, 2023
@k8s-ci-robot k8s-ci-robot merged commit 75889ec into kubernetes:master Jul 4, 2023
@k8s-ci-robot k8s-ci-robot added this to the v1.28 milestone Jul 4, 2023
@danwinship danwinship deleted the proxy-single-dual branch July 5, 2023 13:03
if badCIDRs(s.podCIDRs, badFamily) {
errors = append(errors, fmt.Errorf("cluster is %s but node.spec.podCIDRs contains only IPv%s addresses", clusterType, badFamily))
if s.Config.DetectLocalMode == kubeproxyconfig.LocalModeNodeCIDR {
// This has always been a fatal error
Copy link
Member

Choose a reason for hiding this comment

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

@danwinship I just opened #120999

I believe this PR causes kube-proxy to fail to start with Azure single stack IPv6 in v1.28+

This same configuration wasn't causing issues before

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/kube-proxy cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. 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/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants