-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix HostPort manager when one backend is unavailable #9222
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
Fix HostPort manager when one backend is unavailable #9222
Conversation
Hi @danwinship. Thanks for your PR. I'm waiting for a cri-o member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9222 +/- ##
==========================================
+ Coverage 66.50% 66.52% +0.01%
==========================================
Files 198 198
Lines 27164 27176 +12
==========================================
+ Hits 18065 18078 +13
+ Misses 7612 7611 -1
Partials 1487 1487 🚀 New features to boost your workflow:
|
/ok-to-test |
if err != nil { | ||
// The only likely error is "no such file or directory", in which case any | ||
// further commands will fail the same way, so we don't need to do | ||
// anything special here. | ||
return runner | ||
} |
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 might be too sensitive, but I want to log something every time we get error, especially when it interacts with something not managed by us.
But debug log is enough, I think.
Thank you for the quick fix! |
If `iptables --version` failed, iptables.New() would log a warning and assume that the problem was that you had an implausibly ancient version of iptables installed. Change it to instead assume that the problem is that you don't have iptables installed at all (and only log at debug). Signed-off-by: Dan Winship <danwinship@redhat.com>
Add an internal constructor so that the unit tests share the same logic as the real constructor, and fix it to handle nil sub-managers correctly. Signed-off-by: Dan Winship <danwinship@redhat.com>
cbb5c36
to
b3f1394
Compare
/retest |
@danwinship: The following test failed, say
Full PR test history. Your PR dashboard. 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. I understand the commands that are listed here. |
/skip |
/approve thank you for the quick fix! |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: danwinship, haircommander 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 |
/cherry-pick release-1.33 |
@haircommander: new pull request created: #9241 In response to this:
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. |
The new iptables-and-nftables MetaHostPortManager code was falling victim to a classic golang gotcha. If
newHostportManagerIPTables
returned anil
value (of type*hostportManagerIPTables
), then that value would get assigned tomh.managers[utilnet.IPv4].iptables
, but that value is aHostPortManager
, so the value would be typecast, becoming a non-nil
HostPortManager
value wrapping thenil
*hostportManagerIPTables
value, and then later, this codecri-o/internal/hostport/meta_hostport_manager.go
Lines 143 to 149 in 9d143f9
would see that it was non-
nil
and attempt to call a method on it, which would then SEGV because the underlying*hostportManagerIPTables
wasnil
.There are a few possible ways to fix this... this is one of them...
This wasn't caught by unit tests because the unit tests don't use
NewMetaHostportManager
(since it's not fully mock-able) and it wasn't caught by e2e tests because the e2e environment has both iptables and nftables installed.I also pulled in a cri-o-ified version of kubernetes/kubernetes@
b031258
to get rid of the superfluous error messages also seen in #9220.Fixes #9220
/kind bug
/kind cleanup
Does this PR introduce a user-facing change?