Repository navigation
fix(agent,registrar): close the agent-roll 404 gaps - #142
Merged
Merged
Conversation
The rev-66 helm roll cost ~3.8k loadgen failures, all code=404: proxies were serving with listeners up but route tables missing service vhosts. Root cause analysis found two gaps sharing one flaw — config derived from whatever the registry returns at one instant — plus an amplifier: Gap 1 (~36s, hit HEALTHY nodes that were not even rolling): the helm termination wave floods ENDPOINT_REMOVED events; services whose endpoints all vanish mid-churn dropped out of LoadClustersFromRegistry's wholesale rebuild, and the snapshot pushed route configs with 2 of 8 vhosts to live proxies. Requests to the missing services 404'd — a route-table miss is a lie; the service exists and its pods were coming right back. Fix: services that disappear from the registry listing are retained with their cluster and vhost and an EMPTY endpoint set for a 90s grace (outlasting observed churn windows), then pruned. During the grace, clients get the honest, retriable no-healthy-upstream 503 and recover the instant endpoints reappear. Gap 2 (~170ms but guaranteed): RegistrarRegistry.Initialize starts its watch loop async and returns; the agent's PreListen then derived the initial snapshot from an empty cache and opened the xDS socket serving vhosts=0 — the reconnecting Envoy landed exactly in that window. Fix, in three layers: - protocol: new EVENT_TYPE_SNAPSHOT_COMPLETE marks the end of the initial snapshot stream (sent even when the client is up-to-date), so the client knows its cache holds a complete world view; - client: WaitReady (registry.ReadyWaiter capability) blocks until the first marker; PreListen waits up to 15s before deriving the initial snapshot, then proceeds degraded (existing local-only fallback intact); - registrar: snapshot-serving RPCs (WatchEndpoints, ListAllEndpoints) gate on the syncer's first completed cycle — the co-roll amplifier: without this, a freshly rolled registrar happily serves a complete-but- EMPTY snapshot to every reconnecting agent while still warming from the external registry. The existing rebuild-prunes-stale test is updated to the new graced semantics (retain-empty during grace, prune after); new regression tests cover retention/reappearance/pruning, the client ready machinery through processStream, and the server-side sync gate + marker. Co-Authored-By: Claude Opus 4.8 <[email protected]>
bpalermo
added a commit
that referenced
this pull request
Jun 11, 2026
…p-drain gap (#143) Instrumented two controlled svc rolls (2026-06-11) and pinned the residual ~3-7 fails per pod delete: the drain pipeline itself is fast and correct (deletionTimestamp -> EDS mark on every client in <800ms, zero fails in the propagation window), but Envoy's DRAINING health keeps established H2 pool connections OPEN. They sit idle through preStop and die at the app's shutdown GOAWAY — and streams the server had claimed but not yet answered at that instant fail non-retriably (upstream_rq_rx_reset=0 across all nodes: the app never broke a response; retry_success == retry_total: every retry that could fire succeeded; the fails were the GOAWAY last_stream_id race plus two retry_overflow rejections). Fix: report draining endpoints as UNHEALTHY instead of DRAINING and set close_connections_on_host_health_failure on the service clusters. Pools now close at drain-mark time (~t0+0.8s) while the app is healthy and the pools are idle; anything caught mid-transmit resets pre-request and retries successfully onto a live endpoint. The app-side preStop window is unchanged and still covers genuinely in-progress responses. Supporting changes on the service clusters: - healthy_panic_threshold: 0 — with drainers now counting as unhealthy, a heavy simultaneous roll could cross Envoy's default 50% panic threshold and spray traffic at known-unhealthy hosts; deterministic exclusion + per-request retries + the registry health pipeline are the mesh's answer, not panic spraying. - max_retries circuit breaker 3 -> 16 — the drain-time pool close briefly produces a burst of pre-request resets; the default breaker rejected retries under exactly that burst (retry_overflow observed). Validation plan: re-run the instrumented single-svc roll; expect 0 fails (first-pod-deleted rolls already showed 0 — the fix makes every pod look like the first). Also re-confirmed during instrumentation: zero 404s under churn (the #142 retention guard holding). Co-authored-by: Claude Opus 4.8 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the ~3.8k-failure 404 window from the rev-66 roll. Root-cause investigation reconstructed a per-second timeline; two gaps share one flaw — config derived from whatever the registry returns at a single instant — plus a co-roll amplifier.
Gap 1 — vhost loss on healthy nodes (~36s, the bulk of the damage)
Services that transiently vanish from the registry listing dropped out of
LoadClustersFromRegistry's wholesale rebuild → live proxies received route configs with 2 of 8 vhosts → 404s. A route-table miss is a lie: the service exists.Fix: disappeared services are retained with their cluster + vhost and an empty endpoint set for a 90s grace (outlasting observed churn), then pruned. During the grace clients get the honest, retriable no-healthy-upstream 503 and recover the instant endpoints reappear. (Deliberately chose retention over the investigated count-based hold-down: a count heuristic both masks real deletions and misses same-count swaps.)
Gap 2 — fresh agent serving vhosts=0 (~170ms, guaranteed hit)
RegistrarRegistry.Initializestarts its watch loop async and returns;PreListenderived the initial snapshot from an empty cache and opened the xDS socket — the reconnecting Envoy landed exactly in that window.Fix, three layers:
EVENT_TYPE_SNAPSHOT_COMPLETEmarks the end of the initial snapshot stream (sent even when the client is up-to-date). Backward-compatible: old clients no-op on unknown event types.WaitReady(registry.ReadyWaitercapability) blocks until the first marker;PreListenwaits up to 15s before deriving the initial snapshot, then proceeds degraded (the existing local-only fallback and background retry are untouched — a dead registrar still cannot crash-loop the node).WatchEndpoints,ListAllEndpoints) gate on the syncer's first completed cycle. This kills the actual rev-66 mechanism — without it, a freshly rolled registrar serves a complete-but-empty/partial snapshot to every reconnecting agent while still warming from Cloud Map, and the marker alone would bless garbage.Testing
TestLoadClustersFromRegistry_RetainsDisappearedServices: retain-empty → reappear-restore → prune-after-grace; existing prune test updated to the graced semantics.TestSnapshotCompleteClosesReady: throughprocessStream— marker closes ready, advances the resume token, mutates nothing, idempotent on reconnect markers.TestWatchEndpointsSendsSnapshotComplete,TestWatchEndpointsGatedOnFirstSync,TestListAllEndpointsGatedOnFirstSync.Post-deploy validation: repeat the full-chart co-roll; expect the 404 class gone (fails back to the ~7–14 connection-churn baseline, any residue 503/000-shaped).
🤖 Generated with Claude Code