Skip to content

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

Merged
randomizedcoder merged 7 commits into
mainfrom
feat/uplink-refresh
Nov 27, 2026
Merged

randomizedcoder merged 7 commits into
mainfrom
feat/uplink-refresh

Conversation

@randomizedcoder

@randomizedcoder randomizedcoder commented Nov 27, 2026 •

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 and walks sysfs lower devices (DefaultUplinks); an unchanged list skips the NIC identity read and lldpd, off the hot path.
  • A failed lldpd read keeps the NIC columns and is retried on later ticks, even with the list unchanged (also a startup failure); new outcome lldp_recovered.
  • The stamp is an atomic.Pointer, swapped whole: records never mix two stamps. BenchmarkApplyEnrichmentUplink median 18.66 ns/op on main vs 18.94 here (min 18.48 vs 18.44), 0 allocs.
  • Counters: function="refreshUplinks", outcomes unchanged / changed / lldp_recovered / lldp_error.
  • Tests (red first): refresh once, interval selection, ticker loop + cancel, LLDP retry (recovered after swap, still down, startup failure, healthy), 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 7 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>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A failed lldpd read during a route swap published the new NIC columns
  with empty LLDP ones, and unchanged ticks never fetched again, so the
  LLDP columns stayed empty until the next swap or a restart.
- The refresh loop now carries uplinkState{ifnames, lldpStale}: while
  stale, every tick re-reads lldpd (new outcome lldp_recovered on
  success). A startup lldpd failure is retried the same way.
- Docs: an unchanged tick still reads routes and walks sysfs lower
  devices; it skips the NIC identity read and lldpd (not "/proc only").

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@randomizedcoder
randomizedcoder merged commit cc4e657 into main Nov 27, 2026
1 check passed
@randomizedcoder
randomizedcoder deleted the feat/uplink-refresh branch November 27, 2026 23:14
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