You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
worker/local: root tests intermittently see a NAT pair as not created yet #1471
Two root tests in internal/worker/local fail intermittently in CI's Unit Tests (root) job with the same symptom. A NAT pair's state reads back as Pending, "not created yet", at a step where the test expects it Ready:
Both passed when the job was rerun, both pass repeatedly locally (40 of 40 and 8 of 8 runs), and neither PR changed the code path the failing test exercises.
Expected
The root tests in internal/worker/local pass on every run. If the pair's creation is asynchronous, the tests wait on the condition they assert, or the module reports the pair Ready only once it exists, whichever matches the intended contract.
Acceptance
The fixing PR:
identifies whether the race is in the module or in the tests, with a reproduction (for example under -count with CPU or scheduler stress) that fails before the fix;
makes both tests pass at least 200 consecutive runs as root under the same stress;
A third intermittent root-test failure in internal/worker/local, with a different symptom, on #1478 (which doesn't touch this package):
TestEntryPathsRoot/vlan-generic failed at local_root_test.go:74 with "a second plan would write again". That is the idempotency check, which found work left after a plan had already been applied. A rerun of the job passed. It failed in Actions run 44877885995, job 136766521251, attempt 1.
This may share a cause with the Pending reads above: state that hasn't settled when the test checks it. Whoever fixes this issue should check this test as well, and cover it in the 200-run stress check.
Valid, and the race is in the module, not the tests.
Reproduction (base 1c118386, -race test binary run as root under niced CPU load, 2 or 3 test processes in parallel):
The original TestUntrustedEntryRoot and TestHookWithdrawalAndRepairRoot, 3 processes at -count 40, failed once with the CI symptom: the pair read back as Pending, "the service-internal veth pair is not created yet".
A throwaway steady-state loop failed in both of 2 processes. It builds a ready rig, then runs 3000 reads and dry-run plans per VPC while nothing changes. 4 reads came back Pending and 4 plans came back dirty. A dirty plan is the TestEntryPathsRoot/vlan-generic symptom, "a second plan would write again".
Debug logging in host.readPair traced every one of those to netlink.VethPeerIndex on the tenant end returning unexpected EOF. Both ends existed with the right alias, VRF and ifindex at the time.
In isolation, a plain veth in an empty netns with no XDP attached, netlink.VethPeerIndex fails about once in 300,000 to 1,000,000 calls. The string-set count from ETHTOOL_GSSET_INFO reads back as 0.
So all three failures in this issue share one cause. readPair (internal/worker/local/kernel.go) confirms the pair's peer through two SIOCETHTOOL ioctls. When that lookup fails transiently, readPair reports the pair missing, and then:
Read reports the pair Pending.
Plan reports it missing.
A real Apply calls createPair, which deletes and recreates the live pair. The alias matches, so the collision guard doesn't stop it. Outside the tests, that tears down a working NAT handoff.
The routed-link path (readRouted and the routed-link creation) and cmd/galactic-nat's tenantEndMAC use the same call.
I suspect the lookup fails inside the library's ioctl handling, but I haven't proven that. Its request struct is 24 bytes, while the kernel's struct ifreq is 40.
Fix. Confirm a veth's peer from the netlink link dump Local already reads, instead of an ethtool ioctl. A veth reports its peer's ifindex as IFLA_LINK (Attrs().ParentIndex). IFLA_LINK_NETNSID is absent when the peer is in the same netns.
readPair requires each end's ParentIndex to name the other, with both ends in this netns.
readRouted, routed-link creation, and the routed handoff report read the pod end's index from ParentIndex. readRouted keeps its existing netns-id check.
cmd/galactic-nattenantEndMAC resolves the tenant end through the NAT end's ParentIndex.
Tests.
Unprivileged unit tests for peer matching: matched, mismatched, and peer in another netns.
A steady-state root test: a ready rig, then about 200 consecutive Read and dry-run Plan passes, asserting Ready and an empty plan each time. Without stress it catches the flake only by chance.
The existing assertions stay unchanged.
Verification. Lint, build, unit and root unit tests. The stressed steady-state loop before and after. At least 200 consecutive stressed root runs each of TestUntrustedEntryRoot, TestHookWithdrawalAndRepairRoot and TestEntryPathsRoot/vlan-generic.
Risk. Low. Same checks, read from the same snapshot, with one fewer syscall per link. No API or config change.
Fixed by #1481, merged into integration/galactic-worker as e9888da. Local and galactic-nat now read a veth's peer from the link list, with no ethtool lookup. Under CPU stress, the three tests named here each passed 200 consecutive runs as root.
Reopening: the fix in #1481 doesn't cover every cause. The new TestSteadyStateRoot failed in CI on another PR's branch, which contains #1481 unchanged plus unrelated galactic-nat changes:
lifecycle_root_test.go:68: pass 20: VPC 0000081: a plan would write again
That was the Unit Tests (root) job, run 44900401233, attempt 1. The test passes locally 15 of 15 runs. The failure message doesn't say which object the plan wanted to rewrite, so the next step is to make the test report the planned writes on failure, then find the remaining nondeterministic read.
Activity
privateip commentedon Nov 21, 2026
A third intermittent root-test failure in
internal/worker/local, with a different symptom, on #1478 (which doesn't touch this package):TestEntryPathsRoot/vlan-genericfailed atlocal_root_test.go:74with "a second plan would write again". That is the idempotency check, which found work left after a plan had already been applied. A rerun of the job passed. It failed in Actions run 44877885995, job 136766521251, attempt 1.This may share a cause with the Pending reads above: state that hasn't settled when the test checks it. Whoever fixes this issue should check this test as well, and cover it in the 200-run stress check.
privateip commentedon Nov 21, 2026
Valid, and the race is in the module, not the tests.
Reproduction (base
1c118386,-racetest binary run as root under niced CPU load, 2 or 3 test processes in parallel):TestUntrustedEntryRootandTestHookWithdrawalAndRepairRoot, 3 processes at-count 40, failed once with the CI symptom: the pair read back as Pending, "the service-internal veth pair is not created yet".TestEntryPathsRoot/vlan-genericsymptom, "a second plan would write again".host.readPairtraced every one of those tonetlink.VethPeerIndexon the tenant end returningunexpected EOF. Both ends existed with the right alias, VRF and ifindex at the time.netlink.VethPeerIndexfails about once in 300,000 to 1,000,000 calls. The string-set count fromETHTOOL_GSSET_INFOreads back as 0.So all three failures in this issue share one cause.
readPair(internal/worker/local/kernel.go) confirms the pair's peer through twoSIOCETHTOOLioctls. When that lookup fails transiently,readPairreports the pair missing, and then:createPair, which deletes and recreates the live pair. The alias matches, so the collision guard doesn't stop it. Outside the tests, that tears down a working NAT handoff.The routed-link path (
readRoutedand the routed-link creation) andcmd/galactic-nat'stenantEndMACuse the same call.I suspect the lookup fails inside the library's ioctl handling, but I haven't proven that. Its request struct is 24 bytes, while the kernel's
struct ifreqis 40.privateip commentedon Nov 21, 2026
Approved fix plan:
Fix. Confirm a veth's peer from the netlink link dump Local already reads, instead of an ethtool ioctl. A veth reports its peer's ifindex as
IFLA_LINK(Attrs().ParentIndex).IFLA_LINK_NETNSIDis absent when the peer is in the same netns.readPairrequires each end'sParentIndexto name the other, with both ends in this netns.readRouted, routed-link creation, and the routed handoff report read the pod end's index fromParentIndex.readRoutedkeeps its existing netns-id check.cmd/galactic-nattenantEndMACresolves the tenant end through the NAT end'sParentIndex.Tests.
Verification. Lint, build, unit and root unit tests. The stressed steady-state loop before and after. At least 200 consecutive stressed root runs each of
TestUntrustedEntryRoot,TestHookWithdrawalAndRepairRootandTestEntryPathsRoot/vlan-generic.Risk. Low. Same checks, read from the same snapshot, with one fewer syscall per link. No API or config change.
privateip commentedon Nov 21, 2026
Fixed by #1481, merged into
integration/galactic-workeras e9888da. Local and galactic-nat now read a veth's peer from the link list, with no ethtool lookup. Under CPU stress, the three tests named here each passed 200 consecutive runs as root.privateip commentedon Nov 21, 2026
Reopening: the fix in #1481 doesn't cover every cause. The new
TestSteadyStateRootfailed in CI on another PR's branch, which contains #1481 unchanged plus unrelated galactic-nat changes:lifecycle_root_test.go:68: pass 20: VPC 0000081: a plan would write againThat was the Unit Tests (root) job, run 44900401233, attempt 1. The test passes locally 15 of 15 runs. The failure message doesn't say which object the plan wanted to rewrite, so the next step is to make the test report the planned writes on failure, then find the remaining nondeterministic read.
fix(worker): Read veth peers from the link dump
fix(worker): Read veth peers from the link dump
fix(worker): Read veth peers from the link dump