fix: Explicitly flush guest netns route/address on CNI DEL - #271
Merged
Conversation
Pods with a hostNetwork sandbox plus a Multus secondary VPC attachment got permanently wedged on ADD retry with "configure IPAM: add default route ... file exists", because their args.Netns resolves to the host's own root namespace rather than a distinct per-sandbox one. DEL relied on host-device DEL moving the guest veth end back out of the container netns to flush its address/route as a side effect of crossing a namespace boundary. For a hostNetwork pod that "move" is a no-op (source and destination netns are the same), so the kernel never triggers the flush, and the leftover default route survives indefinitely — there is no ephemeral sandbox netns to reclaim it. The prior ADD-side idempotency fix (00382cf) didn't help here since it only checks for a matching route on the same link, not one left behind by an earlier attempt. flushGuestNetnsConfig now removes the guest interface's default route(s) and non-link-local addresses directly, without deleting the link itself (it's a shared veth pair with host-side VRF wiring other pod instances may still depend on). cmdDel calls it unconditionally ahead of host-device DEL, so cleanup no longer depends on the move-triggered flush firing.
savme
approved these changes
Jul 31, 2026
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.
Summary
Pods with a hostNetwork sandbox plus a Multus secondary VPC attachment got permanently wedged on ADD retry with
configure IPAM: add default route ...: file exists. Theirargs.Netnsresolves to the host's own root namespace rather than a distinct per-sandbox one, since the pod uses hostNetwork.DEL relied on host-device DEL moving the guest veth end back out of the container netns to flush its address/route as a side effect of crossing a namespace boundary. For a hostNetwork pod that "move" is a no-op (source and destination netns are the same), so the kernel never triggers the flush, and the leftover default route survives indefinitely — there's no ephemeral sandbox netns to reclaim it. The prior ADD-side idempotency fix (#269's follow-up,
00382cf) didn't help here since it only checks for a matching route on the same link, not one left behind by an earlier attempt.flushGuestNetnsConfignow removes the guest interface's default route(s) and non-link-local addresses directly, without deleting the link itself (it's a shared veth pair with host-side VRF wiring other pod instances may still depend on).cmdDelcalls it unconditionally ahead of host-device DEL, so cleanup no longer depends on the move-triggered flush firing.Test plan
task linttask buildtask test:unit(root-gated netns tests could not execute in this sandbox — its nested user namespace can't create veth/dummy links at all, confirmed identical onmain; they follow the samerequireRootpattern as pre-existing passing tests)task test:e2e(not run — needs a Kind cluster)