Skip to content

fix(agent,registry): ghost sweep diffs against authoritative listing, not the watch cache - #149

Merged
bpalermo merged 1 commit into
mainfrom
fix/reassert-authoritative
Jun 11, 2026
Merged

bpalermo merged 1 commit into
mainfrom
fix/reassert-authoritative

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

The bug (found by the backend-comparison e2e, 2026-06-11)

The reconnect re-assert (#145) runs the ghost sweep, which lists registry endpoints through the registrar client — served from the watch-fed local cache. On reconnect to a fresh/failed-over registrar whose snapshot is empty, zero FULL_SNAPSHOT events arrive, so the client cache is never cleared (processStream only clears on a FULL_SNAPSHOT event). The cache remains a stale superset claiming every pod is registered → the diff sees nothing missing → re-assert silently no-ops, defeating exactly the state-loss repair it was built for.

In vivo: switching the registrar's backend (cloudmap → dynamodb) left the new registry at services: 0 for minutes while every agent served stale EDS — a latent mesh outage armed for the next agent restart. Only kubectl rollout restart ds/aether-agent (fresh cache = server truth) healed it.

Fix

  • registry.AuthoritativeLister capability: list from the authoritative source, bypassing any cache.
  • Registrar client implements it via the existing ListAllEndpoints RPC (one call per sweep per node, served from the registrar's in-memory snapshot).
  • Ghost sweep prefers it when present; non-caching backends are unaffected.

Considered and rejected: unconditionally re-registering all local pods on reconnect — registrations start at mode-default health (EDS-mode = UNHEALTHY), so benign reconnects would demote healthy serving pods fleet-wide until the next liveness promotion. The authoritative diff re-registers only what's actually missing.

Validation

  • New regression test reproduces the stale-superset trap (cache full, authoritative empty → must re-register).
  • All 38 test targets pass.
  • In-vivo validation planned: the upcoming dynamodb backend switch on talos-main will run without the agent-restart workaround — self-healing repopulation proves the fix.

🤖 Generated with Claude Code

… not the watch cache

The reconnect re-assert (#145) reused the ghost sweep, which listed
endpoints via the registrar client's ListAllEndpoints — served from the
watch-fed local cache. A fresh or failed-over registrar with an EMPTY
snapshot emits no FULL_SNAPSHOT events, so that cache is never cleared:
it remains a stale superset claiming every pod is registered, the diff
concludes nothing is missing, and the re-assert silently no-ops —
defeating exactly the state-loss repair it exists to provide.

Observed in vivo (2026-06-11, backend-comparison e2e): switching the
registrar's external backend left the new registry with zero services
while every agent kept serving stale EDS; only restarting the agents
(fresh cache = server truth) healed it. A registrar fleet replacement
or backend data loss would hit the same latent gap.

Fix: new registry.AuthoritativeLister capability — list from the
authoritative source, bypassing any cache. The registrar client
implements it via the existing ListAllEndpoints RPC; the ghost sweep
prefers it when present. Cost: one RPC per sweep/reconnect per node,
served from the registrar's in-memory snapshot. Regression test
reproduces the stale-superset trap.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@bpalermo
bpalermo merged commit 30fdfc6 into main Jun 11, 2026
10 checks passed
@bpalermo
bpalermo deleted the fix/reassert-authoritative branch June 11, 2026 22:59
bpalermo added a commit that referenced this pull request Jun 12, 2026
…ase 2)

WatchEndpointsRequest gains a ServiceFilter: a filtered watch receives
the snapshot and incremental events for its services only. Unset filter
= full watch; explicitly empty = watch nothing (a node with no mesh
pods). The broadcaster indexes subscribers by service, so an endpoint
change fans out to its consumers instead of every node.

The agent asserts its dependency set as the filter at PreListen and
re-asserts it on every refresher reload (no-op when unchanged); a
changed filter cancels the live stream and reconnects with a cleared
resume token, since newly in-scope services were never delivered to
the old stream. Filter re-assertion on reconnect follows the same
discipline as endpoint re-assertion (#149).

New gauge: aether.registrar.watch.filtered_subscribers.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
bpalermo added a commit that referenced this pull request Jun 12, 2026
…ase 2) (#162)

WatchEndpointsRequest gains a ServiceFilter: a filtered watch receives
the snapshot and incremental events for its services only. Unset filter
= full watch; explicitly empty = watch nothing (a node with no mesh
pods). The broadcaster indexes subscribers by service, so an endpoint
change fans out to its consumers instead of every node.

The agent asserts its dependency set as the filter at PreListen and
re-asserts it on every refresher reload (no-op when unchanged); a
changed filter cancels the live stream and reconnects with a cleared
resume token, since newly in-scope services were never delivered to
the old stream. Filter re-assertion on reconnect follows the same
discipline as endpoint re-assertion (#149).

New gauge: aether.registrar.watch.filtered_subscribers.

Co-authored-by: Claude Opus 4.8 <[email protected]>
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