Skip to content

test(e2e): name the stalled hop when the replicator failover assertion flakes - #599

Merged
bpalermo merged 1 commit into
mainfrom
fix/e2e-597-failover-diagnostics
Jul 26, 2026
Merged

bpalermo merged 1 commit into
mainfrom
fix/e2e-597-failover-diagnostics

Conversation

@bpalermo

Copy link
Copy Markdown
Owner

The replicator suite intermittently fails step 3's negative assertion — client(a) must stop reaching echo once region-b's mirror expires from etcd-a. The registry half is provably fine (mirror expires at 0s, b's origin data persists); what flakes is the data path outliving the registry state, and today that failure says nothing beyond "still 200".

That matters more than a loose budget suggests. The withdrawal path is watch-driven end to end — a's registrar syncs off the etcd watch with the 5s poll as a mere backstop (registrar/internal/server/sync.go, registry/internal/etcd/etcd.go), and the agent pushes xDS off the resulting broadcast. Designed latency is sub-second plus debounce, so exceeding 30s is ~2 orders of magnitude off the designed path, not a marginal overrun.

Widening the window would bury one of three materially different causes, so this instruments the hops instead. No timeout, retry budget, or production code is touched.

dump_failover_state() — on the failure path, before die

Section Discriminates
registry — region-b keys in both etcds re-printed at failure time so the log is self-contained
registrar — two greps of a's logs: watch establish/re-establish + lease/leader/mirror lines, then the sync cadence (1) the watch lapsed and we degraded to the 5s poll, vs (2) a replicator leader-election / mirror-stream gap
agent — snapshot rebuilds + dependency-set transitions for echo, plus aether_agent_snapshot_* metrics first half of (3)
envoy — the echo cluster's hosts from admin /clusters proves or clears (3) outright

Two registrar greps rather than one because the chart runs everything with --debug, so per-cycle chatter would otherwise crowd the rare decisive lines out of any single tail.

(3) is the consequential one: hosts still present would mean cross-cluster failover latency is bounded by something other than the origin-heartbeat lease, defeating the design's premise.

A final post-dump probe distinguishes "merely overran the budget" from "never withdrew" — diagnostic only, the assertion has already been decided.

Reaching the Envoy/xDS layer

Envoy's admin binds 127.0.0.1:9901 and both the proxy and agent images are distroless, so there is no kubectl exec route to it. Both DaemonSets are hostNetwork, so the kind node container shares their netns and docker exec <node> curl reaches admin and the agent's :8080 metrics — the same shape as the existing etcdctl dumps, and kindest/node ships curl (verified). Kept to a one-shot failure-path dump: /clusters renders on Envoy's main thread, which is why nothing in aether scrapes it.

Waypoint harness

The failover dump doesn't apply — that suite has one shared etcd, no replicator, no registrar kill, and no withdrawal assertion. But its die message literally instructed a human to "inspect a's EDS for echo", so dump_echo_eds() now does it: ~20 lines, same #590 principle, and the one hop dump_mesh_dns cannot speak for.

Verification

  • bash -n clean on both scripts.
  • shellcheck (via .shellcheckrc, shell=bash): zero new findings — the two reported (SC2034 TUNNEL_PORT, SC2155 in waypoint install_aether) are byte-identical on HEAD.
  • bazel run //:format + make format-check clean.
  • Both helpers smoke-tested under set -euo pipefail with stubbed kubectl/docker: all-tools-failing, happy path, envoy-holds-echo, envoy-dropped-echo, and node-unresolved branches all return 0 and print the intended section.

Refs #597.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EioJVuoepwStjHoRLB52WR

…n flakes

The `replicator` suite intermittently fails step 3's NEGATIVE assertion:
`client(a)` must stop reaching `echo` once region-b's mirror expires from
etcd-a. The registry half is provably fine (the mirror expires at 0s, b's
origin data persists) — what flakes is the data path outliving the registry
state, and today that failure says nothing beyond "still 200".

That matters more than a loose budget would suggest. The withdrawal path is
watch-driven end to end: a's registrar syncs off the etcd watch with the 5s
poll as a backstop (`registrar/internal/server/sync.go`,
`registry/internal/etcd/etcd.go`), and the agent pushes xDS off the resulting
broadcast. Designed latency is sub-second plus debounce, so exceeding 30s is
~2 orders of magnitude off the designed path, not a marginal overrun.

Widening the window would bury one of three materially different causes, so
instrument the hops instead. `dump_failover_state()` prints, on the failure
path before `die`:

- registry — region-b keys in both etcds, so the log is self-contained;
- registrar — two greps of a's logs (the per-cycle `--debug` chatter would
  otherwise crowd the decisive lines out of a single tail): watch
  establish/re-establish and lease/leader/mirror lines, then the sync cadence.
  This is what separates "the watch lapsed and we degraded to the 5s poll"
  from "a replicator leader-election gap";
- agent — snapshot rebuilds and dependency-set transitions for `echo`, plus
  the `aether_agent_snapshot_*` metrics;
- envoy — the `echo` cluster's hosts from admin `/clusters`, which proves or
  clears the consequential cause outright: hosts still present would mean
  cross-cluster failover latency is bounded by something other than the
  origin-heartbeat lease, defeating the design's premise.

Envoy's admin binds 127.0.0.1:9901 and both images are distroless, so there is
no `kubectl exec` route to it. The proxy and agent are hostNetwork, so the kind
node container shares their netns and `docker exec <node> curl` reaches both
admin and the agent's metrics — the same shape as the existing etcdctl dumps.
Kept to a one-shot failure-path dump: `/clusters` renders on Envoy's main
thread, which is why nothing in aether scrapes it.

The waypoint harness has no withdrawal assertion, so the failover dump does not
apply — but its `die` message literally instructed a human to "inspect a's EDS
for echo", so `dump_echo_eds()` now does that too.

Retry budget, timeouts, and production code are all untouched: the point is to
identify the stalled hop first.

Refs #597.

Co-Authored-By: Claude <[email protected]>
Claude-Session: https://claude.ai/code/session_01EioJVuoepwStjHoRLB52WR
@bpalermo
bpalermo merged commit 9902bc5 into main Jul 26, 2026
15 checks passed
@bpalermo
bpalermo deleted the fix/e2e-597-failover-diagnostics branch July 26, 2026 15:49
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