[ipam/eni] Wait for ENI interface in the CNI plugin before configuring routes - #675
Closed
jaredledvina wants to merge 1 commit into
Closed
[ipam/eni] Wait for ENI interface in the CNI plugin before configuring routes#675jaredledvina wants to merge 1 commit into
jaredledvina wants to merge 1 commit into
Conversation
jaredledvina
force-pushed
the
jared.ledvina/fixup-eni-ifindex-race
branch
7 times, most recently
from
July 24, 2026 20:54
c0a0a2d to
fe893a6
Compare
Signed-off-by: Jared Ledvina <jared.ledvina@datadoghq.com>
jaredledvina
force-pushed
the
jared.ledvina/fixup-eni-ifindex-race
branch
from
July 28, 2026 15:57
fe893a6 to
b9037bc
Compare
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.
Please ensure your pull request adheres to the following guidelines:
description and a
Fixes: #XXXline if the commit addresses a particularGitHub issue.
Fixes: <commit-id>tag, thenplease add the commit author[s] as reviewer[s] to this issue.
in accordance with the [Cilium AI Policy], and indicate the rating using
[AI Influence Level].
Example: "This PR was prepared with AIL:3. I personally checked X."
This PR was prepared with AIL:3. I personally checked the logic, tests, and build/CI results.
This PR was prepared with AIL:3. I personally checked the logic, tests, and build/CI results.
In AWS ENI IPAM mode, ENI attachment is asynchronous: the operator can report an
ENI as attached (and cilium-agent can hand out an IP from it) before the ENI's
netlink interface is visible on the node. Any code that resolves the ENI's
ifindex by MAC address immediately afterwards can lose that race and fail with
interface with MAC ... not found.Upstream cilium#47295 has since merged and fixes the
cilium-agentsideof this, in
daemon/infraendpoints/infra_ip_allocation.go. It does not touchthe
cilium-cniplugin, which is a separate binary with its own callers ofRoutingInfo.Configure(), and those are still exposed:interfaceAddinplugins/cilium-cni/cmd/interface.goconfigures ip rules androutes on every CNI ADD. When it loses the race, CNI ADD fails outright with
unable to setup interface datapath: unable to install ip rules and routes: unable to find ifindex for interface MAC: interface with MAC ... not foundand the pod is left in
ContainerCreating.IPAMENIbranch ofCmd.Addinplugins/cilium-cni/cmd/cmd.goresolvesthe master MAC via
ifindexFromMacand only logs on failure, leavingep.ParentInterfaceIndexat 0. That silently breaks IPv4 masquerade replyrouting (
nodeport_snat_fwd_ipv4) for the endpoint.Upstream's guard cannot be reused as-is from the plugin: its
waitForENIis anunexported method on
infraIPAllocator, unreachable from a separate binary.This PR therefore:
WaitForENIInterface(ctx, mac.MAC)inpkg/datapath/linux/routing/routing.go, so both binaries can share oneimplementation, and reduces the agent's
waitForENIto anet.ParseMACplusa delegation to it.
pkg/datapath/linux/routing/routing_test.gocovering interfacealready present, interface appearing after a delay (the race being guarded),
timeout, and context cancellation, plus a case for the new invalid-MAC error
in
daemon/infraendpoints.The ingress-path hunk this PR originally carried has been dropped: upstream's
merged version is strictly better, because it also gates on
IPAMAlibabaCloud(the ingress
Configure()runs in that mode too) and logs atErrorratherthan
Warn.One item for reviewer attention. The shared backoff uses
Steps: 7(~15.75s worst case before jitter) where upstream's is
Steps: 5(~3.75s). Thelonger window is intended for CNI ADD, where a real ENI attach can exceed a few
seconds and kubelet retries anyway, but because the constant is now shared it
also applies to the agent's router and ingress paths. Confirm that is wanted, or
say so and I will scope the longer backoff to the plugin only.
Verified:
gofmt,GOOS=linux go build,GOOS=linux go vetandgolangci-lint(v2.12.2, repo pin) are clean on the three touched packages.The new routing tests are
TestPrivileged*and need Linux netns plus root, sothey have not run locally — they need CI or a Linux VM.
References: cilium#47295 (merged, agent side), cilium#41954,
cilium#45414