-
Notifications
You must be signed in to change notification settings - Fork 40.7k
kube-proxy: log iptables errors in platformCheckSupported #131534
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: log iptables errors in platformCheckSupported #131534
Conversation
This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the The 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-sigs/prow repository. |
665b9c1
to
cd26436
Compare
cd26436
to
265c370
Compare
265c370
to
771bb51
Compare
pkg/util/iptables/iptables.go
Outdated
} | ||
|
||
return true | ||
return true, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bool is redundant at this point. Just have it return an error only.
cmd/kube-proxy/app/server_linux.go
Outdated
ipts, err = utiliptables.NewDualStack() | ||
if err != nil { | ||
logger.Error(err, "Encountered errors in setting up iptables") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would merge this with the existing error handling: if neither ipv4 nor ipv6 is supported, wrap this error as part of the return value from this function. If only one of them is not supported, log the error message as part of the "no support for family" message below (keeping it as logger.Info
since it's probably an intentional configuration rather than an error in that case)
771bb51
to
029484a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
basically good, just some nitpicks
interfaces[v1.IPv6Protocol] = iptv6 | ||
} | ||
|
||
return interfaces | ||
return interfaces, errors.NewAggregate(errs) | ||
} | ||
|
||
// NewDualStack returns a map containing an IPv4 Interface (if IPv4 iptables is supported) | ||
// and an IPv6 Interface (if IPv6 iptables is supported). If either family is not | ||
// supported, no Interface will be returned for that family. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The semantics are slightly tricky now so we need to document that:
// Note that this function will return a single iptables Interface *and* an error, if only
// a single family is supported.
pkg/util/iptables/iptables.go
Outdated
iptv6 := newInternal(exec, ProtocolIPv6, "", "") | ||
if iptv6.Present() { | ||
if err := iptv6.Present(); err != nil { | ||
errs = append(errs, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we get an error for both IPv4 and IPv6, it's virtually guaranteed that they're going to be the same error. So I would say that rather than combining the two, we should just ignore the IPv6 error and return only the IPv4 error in that case.
So:
- if both
Present()
calls fail, then return the error fromiptv4.Present()
- if one
Present()
call succeeds and one fails then return the error from the one that failed - (if both succeed then return no error)
This reverts commit 9cb3dfb.
029484a
to
cbe1be3
Compare
/lgtm |
LGTM label has been added. Git tree hash: 332322d7262e9c4c360992487b6af31f5a401440
|
// If we get an error for both IPv4 and IPv6 Present() calls, it's virtually guaranteed that | ||
// they're going to be the same error. We ignore the error for IPv6 if IPv4 has already failed. | ||
if err == nil { | ||
err = presentErr | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
errors.Join is supposed to solve this problem https://pkg.go.dev/errors#Join
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was using NewAggregate(errs)
from k8s.io/apimachinery/pkg/util/errors
previously. If both the proxiers fails, they will fail with the same error only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, the point is, we don't want to see "iptables: command not found, ip6tables: command not found". Just "iptables: command not found" is enough.
pkg/kubelet/kubelet_network_linux.go
Outdated
@@ -37,7 +37,7 @@ const ( | |||
) | |||
|
|||
func (kl *Kubelet) initNetworkUtil() { | |||
iptClients := utiliptables.NewDualStack() | |||
iptClients, _ := utiliptables.NewDualStack() | |||
if len(iptClients) == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this please be changed to:
if len(iptClients) == 0 { | |
if err != nil || len(iptClients) == 0 { |
And err
added to the log.
Relying on return value when the err is not nil is not a good practice
Signed-off-by: Daman Arora <[email protected]>
cbe1be3
to
858b88b
Compare
/approve |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
/unhold
LGTM label has been added. Git tree hash: 0cd76d558526a36f8ba3e4f9a6abe1a1b84e2f64
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: aroradaman, danwinship, SergeyKanzhelev, 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 |
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:
You can:
/retest |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Currently we check the existence of the default iptables chain to ensure if iptables is supported by the platform. We don't log the actual error and stdout when the check fails.
Logging the actual stdout/stderr will help to understand the root cause of the actual failure. It can help in covering the cases when privileges are not properly configured for the kube-proxy daemonset, removal of a deprecated flag from the user space binary and many more.
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: