fix(k8s): use the node's configured iptables backend for node prep - #2145
Open
guanchzhou wants to merge 1 commit into
Open
fix(k8s): use the node's configured iptables backend for node prep#2145guanchzhou wants to merge 1 commit into
guanchzhou wants to merge 1 commit into
Conversation
The node-prep script hardcodes /usr/sbin/iptables-nft for the two TCP MSS clamping rules, but the default node image runs a kernel with no nftables support, so those calls always fail: $ ls /proc/net/nf_tables* ls: cannot access '/proc/net/nf_tables*': No such file or directory $ /usr/sbin/iptables-nft -t mangle -S iptables v1.8.11 (nf_tables): Could not fetch rule set generation id: Invalid argument /usr/sbin/iptables resolves through alternatives to the backend the image is actually set up for -- legacy in kindest/node -- and the same two rules apply cleanly through it. On an image whose kernel does carry nftables, alternatives selects nft, so naming iptables is strictly more portable than naming a specific backend. Because nodePrepScript runs under set -e and these are its last two lines, the failure aborts node prep and surfaces the accumulated stdout of the commands that already succeeded, which is why the reported error names a sysctl that worked rather than the command that failed. Fixes apple#2120
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2120
The node-prep script hardcodes
/usr/sbin/iptables-nftfor its two TCP MSS clamping rules, but the default node image runs a kernel with no nftables support, so those calls can never succeed andset -eaborts node prep.Evidence, inside a node left behind by a failed
container k8s createThe same two rules, unchanged, applied through
/usr/sbin/iptables:Why name
iptablesrather than a backendalternativesresolvesiptablesto whichever backend the image is configured for. Onkindest/nodethat is legacy, which works; on an image whose kernel does carry nftables it selects nft. Naming a specific backend is what makes the script image-dependent, so this is strictly more portable than the line it replaces.Appending
|| truewould also stop the abort, but it would silently drop the MSS clamping those rules exist to provide.A note on the confusing error message
Because
nodePrepScriptruns underset -eand these are its last two lines, the failure aborts prep and what surfaces is the accumulated stdout of the commands that already succeeded:That names a
sysctlthat worked and an image tag that worked, not the command that failed. Not changed here, but surfacing the failing command's stderr would make this class of failure self-diagnosing. Two smaller observations from the same reproduction, also left alone: a create that fails leaves the node running and holding its published port, and--cpus/--memorymake no difference (reproduced at 2/4 GiB as well as the reporter's 6/16 GiB).Verification
swift build --product containerandswift build --target k8sboth succeed.iptablesapplies both rules.container k8s createwith the patched plugin installed. That needs the built plugin placed into the install root in place of the packaged one, which I did not want to do on this machine. If you would like that run before merging, say so and I will do it.Environment: macOS 27.0 (Tahoe), Apple silicon,
container1.2.2 from the Homebrew formula, node imagedocker.io/kindest/node:v1.35.5@sha256:ce977ae…(the plugin default).Per CONTRIBUTING: I used AI assistance while investigating and drafting, and I can explain and justify both changed lines — the change is a substitution of one shell binary for another, and the reasoning is the nftables-absence evidence above.