Skip to content

fix(agent): restore the default panic threshold — #143's panic-0 unmasked the Cloud Map registration race - #144

Closed
bpalermo wants to merge 1 commit into
mainfrom
fix/restore-panic-threshold
Closed

bpalermo wants to merge 1 commit into
mainfrom
fix/restore-panic-threshold

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

The rev-68 e2e went RED — svc rolls cost 352/439 fails (vs 14–27 pre-#143), nearly all sustained no_healthy_upstream 503s in 30–70s windows. The #143 drain machinery itself is working (config confirmed on the wire; the GOAWAY-race code=000 class shrank to ~6/pod; retry_success == retries, retry_overflow: 0 on the 16-deep breaker; zero 404s everywhere).

What actually broke

The pre-existing Cloud Map async-registration race: a brand-new (healthy, serving) pod's registration can fail (failed to register endpoint; reconciliation sweep will retry) and only the 60s sweep retries it. During a roll, the recorded healthy fraction can hit zero while real capacity exists. Pre-#143, Envoy's default 50% panic threshold was the accidental safety net — it sprayed traffic across all known hosts (unregistered-but-serving newcomers were absent, but draining-yet-alive old pods caught it) and rolls stayed cheap. healthy_panic_threshold: 0 removed the net and exposed the rot as hard no-route windows.

This PR

Remove the HealthyPanicThreshold: 0 override (back to Envoy's default 50%); keep the rest of #143 (drain-mark UNHEALTHY, close_connections_on_host_health_failure, max_retries: 16). The comment now documents why panic stays: it is the correct safety net for exactly this failure mode — bookkeeping wrong, capacity real — and must remain until the bookkeeping is trustworthy.

Follow-up (the real fix, next PR)

Fast-retry failed endpoint registrations / health promotions in the agent (seconds with backoff, not the 60s sweep). Once the recorded healthy fraction stays truthful through rolls, panic never engages and the #143 target (0-fail rolls) becomes reachable — at that point panic-0 can be revisited with evidence.

Full suite 38/38. Post-deploy validation: repeat the svc-1 roll — expect back at/below the pre-#143 14–27 band (GOAWAY class now fixed, so likely ~6×4=24 worst case, plausibly under).

🤖 Generated with Claude Code

…sked the Cloud Map registration race

The rev-68 e2e went RED: svc rolls cost 352/439 fails (vs 14-27 pre-#143),
nearly all sustained no_healthy_upstream 503s. Diagnosis: the pre-existing
Cloud Map async-registration race can leave brand-new (healthy, serving)
pods unregistered for up to the 60s reconciliation sweep ("failed to
register endpoint; reconciliation sweep will retry"). During a roll the
RECORDED healthy fraction can therefore hit zero while real capacity
exists — and pre-#143, Envoy's default 50% panic threshold was the
accidental safety net: it sprayed traffic across all known hosts
(including the unregistered-but-serving and draining-but-alive ones) and
rolls stayed cheap. #143's healthy_panic_threshold: 0 removed the net and
exposed the rot as hard no-route windows.

Restore the default panic threshold (keep the rest of #143: drain-mark
UNHEALTHY, close_connections_on_host_health_failure, max_retries 16 — all
confirmed working: the GOAWAY-race code=000 class shrank to ~6/pod and
every retry succeeded). Panic spraying is the correct safety net for
exactly this failure mode: bookkeeping wrong, capacity real.

Follow-up (the real fix, separate PR): fast-retry failed endpoint
registrations/health promotions in the agent (seconds, not the 60s
sweep), after which the recorded healthy fraction stays truthful through
rolls and panic never engages.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@bpalermo bpalermo closed this Jun 11, 2026
@bpalermo
bpalermo deleted the fix/restore-panic-threshold branch June 11, 2026 17:51
bpalermo added a commit that referenced this pull request Jun 11, 2026
Closes the Cloud Map registration race that the rev-68 e2e exposed (and
that the default panic threshold had been silently masking): a failed
external-registry write left a serving pod invisible to the mesh for up
to the 60s reconciliation sweep, driving the recorded healthy fraction of
a rolling service to zero while real capacity existed. Per the design
decision (2026-06-11): discovery moves at watch latency; the external
registry — and therefore cross-cluster visibility — is eventually
consistent. panic_threshold stays 0 (#144 closed unmerged); this is the
fix that has to carry it.

Registrar:
- RegisterEndpoint/UnregisterEndpoint are now snapshot-first: apply +
  broadcast immediately, never fail the RPC on external-registry errors.
  The external write goes to a per-replica write-behind queue (1s..30s
  backoff, 5m max age with loud drop).
- Pending-shielding: the sync loop overlays still-pending intents onto
  the fetched external state BEFORE Diff/Replace, so neither the
  broadcast events nor the wholesale snapshot replacement can regress an
  intent the external registry has not materialized yet (the rev-66
  partial-view bug, approached from the write side). An op is released
  only after its write succeeded AND a sync observes the intent.
- Metrics: writebehind.queue_depth / flush_failures / drops /
  shielded_intents.

Agent:
- The registry watch client signals each successful (re)connection
  (registry.ReconnectNotifier); the CNI server runs an immediate ghost
  sweep on it, re-asserting this node's registrations. A failed-over or
  restarted registrar replica that lost queued intents is repaired at
  reconnect speed instead of the sweep interval.

Chart:
- registrar replicaCount default 1 -> 2 (directive: always exercise the
  multi-replica topology). With 2 replicas, both serve gRPC and sync
  independently; an RPC-driven change is visible instantly on the
  receiving replica and converges on the peer via the external registry —
  peer-watch (origin-tagged replica-to-replica subscriptions over the
  existing WatchEndpoints protocol) is the planned phase 2 that closes
  that skew.

Validation criterion on talos: svc-1 rolling restart under load with
panic still 0 -> ~0 fails (rev-68 baseline: 352/439).

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