flannel-migration: flush leftover Flannel iptables chains on node cleanup - #12920
Open
stitrace wants to merge 1 commit into
Open
flannel-migration: flush leftover Flannel iptables chains on node cleanup#12920stitrace wants to merge 1 commit into
stitrace wants to merge 1 commit into
Conversation
…anup When migrating a node to Calico the controller removes the Flannel daemonset and deletes the Flannel tunnel/bridge devices (flannel.<vni>, cni0), but it never removes the iptables chains Flannel programs: FLANNEL-POSTRTG in the nat table and FLANNEL-FWD in the filter table. Those chains survive the migration. The masquerade rule in FLANNEL-POSTRTG SNATs cross-node pod-to-pod traffic to the node's tunnel IP. This is harmless until a NetworkPolicy is applied: the SNAT'd source address no longer matches pod-selector rules, so Calico's default-deny drops the traffic. The result is that, after an otherwise successful migration, cross-node connections to any pod covered by a NetworkPolicy silently time out, while same-node traffic keeps working because Flannel's own RETURN rules exempt the node-local subnet. Flush FLANNEL-POSTRTG and FLANNEL-FWD as part of the existing per-node remove-flannel step so Calico (cali-nat-outgoing) becomes the sole owner of pod masquerading. Both the legacy and nft iptables backends are cleaned and every command is idempotent.
Contributor
|
@projectcalico/core-maintainers Would you have a look also at the corresponding doc ticket? tigera/docs#2768 |
caseydavenport
approved these changes
Jul 23, 2026
caseydavenport
left a comment
Member
There was a problem hiding this comment.
Sorry for the long delay on this - it LGTM
I'd generally want to see an FV test of some sort, but it seems we don't really have a good framework in place to add that to at the moment so we'll defer that for now!
Member
|
/sem-approve |
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.
Description
When the flannel-migration controller migrates a node to Calico it:
flannel.<vni>, andcni0for non-Canal flannel) via the per-noderemove-flannelpod inremoveFlannelNetworkAndInstallDummyCalicoCNI.It does not remove the iptables chains Flannel installs:
FLANNEL-POSTRTG(nat) andFLANNEL-FWD(filter). These are programmed byflanneldat runtime and are not cleaned up when the daemonset/devices are removed, so they persist after an otherwise successful migration.Why it matters
FLANNEL-POSTRTGcontains:with
RETURNexceptions only for the node-local subnet. After migration this rule keeps masquerading cross-node pod-to-pod traffic to the source node's VXLAN tunnel IP (<block>.0).This is invisible until a
NetworkPolicyis applied. Once it is, the SNAT'd source address no longer matches pod-selector / same-namespace rules, so Felix's default-deny drops the traffic. Symptom: after a clean migration, cross-node connections to any pod covered by a NetworkPolicy silently time out, while same-node traffic keeps working (Flannel's own RETURN rules exempt the node-local subnet). Calico's owncali-nat-outgoingcorrectly does not masquerade pod-to-pod, so it's purely the leftover Flannel chain.Reproduction
nft list chain ip nat POSTROUTINGon any node still showsjump FLANNEL-POSTRTG(non-zero counters).<block>.0tunnel IP instead of the client pod IP.Fix
Flush
FLANNEL-POSTRTGandFLANNEL-FWDas part of the existing per-noderemove-flannelstep, so Calico becomes the sole owner of pod masquerading. The cleanup:calico/nodepod that already deletes the devices;Testing
FLANNEL-POSTRTGpersists post-migration, SNATs cross-node pod traffic to the tunnel IP, and breaks NetworkPolicy; removing the chains restores cross-node policy traffic with no other changes.gofmt-clean. I was not able to run the flannel-migration FV suite locally; happy to iterate.Release Note