Skip to content

fix(xtcp): uplinks follow a route change - #354

Open
randomizedcoder wants to merge 5 commits into
mainfrom
feat/uplink-refresh
Open

randomizedcoder wants to merge 5 commits into
mainfrom
feat/uplink-refresh

Conversation

@randomizedcoder

Copy link
Copy Markdown
Owner
  • Uplink columns were computed once at startup; a default-route metric swap moved egress but the uplink columns stayed stale until restart.
  • Auto-detected uplinks now refresh on locality_refresh_interval (default 60s, 0 = never); pinned UplinkInterfaces never refresh.
  • Each tick re-reads the default routes (a cheap /proc read); only a changed list re-reads sysfs and lldpd, off the hot path.
  • The stamp is an atomic.Pointer, swapped whole: records never mix two stamps. BenchmarkApplyEnrichmentUplink ~18-20 ns/op vs ~18 before, 0 allocs.
  • Counters: function="refreshUplinks", outcomes unchanged / changed / lldp_error.
  • Tests (red first): refresh once, interval selection, ticker loop + cancel, concurrent apply under -race.
  • Golden VM: new row uplink_follows_metric swaps the ionic0/e1000e route metrics and expects e1000e,ionic on a later poll; the kept poll is from before the swap, so the fixture is unchanged (xtcp2-golden diff clean).

🤖 Generated with Claude Code

randomizedcoder and others added 5 commits November 27, 2026 00:18
Table tests for the uplink refresh: a metric swap moves the stamp, an
unchanged list skips sysfs and lldpd, a lost uplink falls back to the
physical NICs, lldpd failing keeps the NIC columns, the refresh interval
rules, the ticker loop, and a race test that a record never mixes two
stamps. They don't build yet: uplinkSources and the refresh are next.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The uplink columns were chosen once at startup, so a route-metric swap
moved egress and locality within a refresh but left the uplinks naming
the old interface until a restart.

Auto-detected uplinks are now re-read every locality_refresh_interval
(0 = never; pinned uplink_interfaces are never re-read). The stamp is an
atomic.Pointer swapped whole, so a record never mixes two. An unchanged
list costs one /proc read; a changed one is read again from sysfs and
lldpd off the hot path. Outcomes count under function=refreshUplinks:
unchanged, changed, lldp_error.

applyEnrichment: 18.2-20.1 ns/op vs 17.9-18.2 before (host load 5-9),
0 allocs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After poll 2 (the fixture) the capture moves the e1000e's default route
in front of ionic0's, waits for refreshUplinks to count the change and
for a poll that starts after it, and checks that poll's uplink1 is the
e1000e. stop_and_fetch_second_poll takes an optional path for the newest
object; with one argument it behaves as before (families). The golden
collector refreshes every 5s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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