Skip to content

fix(nat): remove Local pair state when Worker integration is off - #1480

Merged
privateip merged 6 commits into
integration/galactic-workerfrom
fix/issue-1479
Nov 21, 2026
Merged

privateip merged 6 commits into
integration/galactic-workerfrom
fix/issue-1479

Conversation

@privateip

@privateip privateip commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Restarting the NAT shard with its Worker integration or its datapath off left every local pair attached and translating until Worker's claims expired, about 2 minutes later.

That restart now detaches the pairs and empties their tables at once. A node that never ran the shard is left untouched. The lab case checks this and drops its manual cleanup.

Test plan

  • Unit, lint, build and privileged suites pass. The privileged test fails without the VLAN table fix
  • A restart with the integration off removes a previous run's links and rows; a second restart changes nothing
  • e2e passes in CI
  • The lab's local-shard case passes, and the lab is left clean and matching its baseline

Fixes #1479

galactic-nat pins an XDP link for each Local pair's NAT end and writes
rows to nat_local_pair, nat_local_return and nat_vlan_egress. Only the
running Worker integration removed them. A start with worker_socket
empty or the datapath disabled left them in place, and the pairs kept
translating until Worker withdrew the claims at lease expiry.

That start now prunes with an empty keep set. With the datapath
loaded, it uses the loaded maps. With the datapath disabled, it opens
the pinned maps and treats a missing pin as empty, so a node that never
ran galactic-nat stays untouched. A failure is logged, like
turnOffDatapath's, and startup continues.

Prune with an empty keep set now also clears nat_vlan_egress. Its only
writer is kernelLocal.syncVLANs, and nat.c only reads it. Prune also
treats a missing links directory as empty.

The lab case now checks that galactic-nat removed its pins and rows on
its own after restarting without the socket, and drops the manual
rm and bpftool deletes.

Fixes #1479
@privateip privateip self-assigned this Nov 21, 2026
@privateip

Copy link
Copy Markdown
Contributor Author

Clearing all of nat_vlan_egress when no pair is kept is safe because the Local path is that map's only writer. Checked with git grep at f32863f, the PR's base:

  • cmd/galactic-nat/workerlocal.go:178 and :184: kernelLocal.syncVLANs calls k.vlans.Put and k.vlans.Delete. It is the only caller of natmap.VLANTable's write methods, and workerwatch.go:206 is the only place that table is built.
  • internal/plumbing/ebpf/natprog/nat.c:1391: the datapath reads the map with bpf_map_lookup_elem(&nat_vlan_egress, ...). It never updates or deletes it.

Nothing else in Go or eBPF references the map, apart from the two lab scripts.

Merging integration added a third use of the pair names in workerlocal_test.go, which goconst flags.
@privateip

Copy link
Copy Markdown
Contributor Author

Lab evidence for 1026f38 on the shared containerlab, deployed from integration dc79653. Only galactic-nat was replaced with this branch's build, on the dfw NAT nodes.

Step Result
Restart galactic-nat without a Worker socket Every pod logged the startup cleanup. dfw-worker2 had no local-* pins and 0 rows in all three Local maps
verify:nat-sharding, verify:nat-egress, verify:nat-return-route, verify:nat-active-active Pass
verify:nat-local-shard Pass
verify-nat-local-clean.sh assert Pass
baseline:twice (handoff) Runs 1 and 2 identical and matching the committed reference

The teardown restarts galactic-nat without GALACTIC_NAT_WORKER_SOCKET. Its new check then found the pins and rows gone while 4 Local pair links were still present, before Worker withdrew its claims:

galactic-nat removed its local link pins and pair rows at startup (4 Local pair links still present)
waiting for Worker to withdraw galactic-nat's claims (session lease 120 s)
Local's pairs are gone

No manual removal of galactic-nat state ran. The script no longer has one.

CI: the first attempt of Unit Tests (root) on 0a8ad13 failed internal/worker/local TestSteadyStateRoot, which this PR doesn't touch. That failure is tracked in #1471. The rerun passed, and every check on the current head passes.

The startup cleanup sentence left one line at 95 characters.
@privateip privateip changed the title fix(nat): stop local pairs translating once Worker integration is off fix(nat): remove Local pair state when Worker integration is off Nov 21, 2026
@privateip
privateip marked this pull request as ready for review November 21, 2026 15:31
@privateip
privateip requested a review from a team as a code owner November 21, 2026 15:31
@privateip
privateip merged commit 252ce63 into integration/galactic-worker Nov 21, 2026
29 checks passed
@privateip
privateip deleted the fix/issue-1479 branch November 21, 2026 15:32
@privateip

Copy link
Copy Markdown
Contributor Author

Review record:

  • Adversarial review: merge, no findings.
  • Conventions review: hold. Its two decision items were already settled:
  • Conventions findings:
    • The merge-commit warning was declined. This branch takes integration changes by merge.
    • Both nits are fixed in a4ac385: the PR title now matches the commit subject, and the long docs line is reflowed.

The base branch has no review rule, so auto-merge completed on green CI.

privateip added a commit that referenced this pull request Nov 24, 2026
fix(nat): remove Local pair state when Worker integration is off
privateip added a commit that referenced this pull request Nov 30, 2026
fix(nat): remove Local pair state when Worker integration is off
privateip added a commit that referenced this pull request Dec 2, 2026
fix(nat): remove Local pair state when Worker integration is off
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant