Repository navigation
Description
Symptom
The replicator job in the e2e workflow intermittently fails at step 3/4 on the negative assertion:
✓ mirror expired in etcd-a 0s after origin death (origin-heartbeat lease lapse, no peer GC)
✓ origin data intact in etcd-b (only the mirror expired)
✗ client(a) still reaches echo after region-b mirror expired
Confirmed non-deterministic: run 30202321468 failed and an immediate re-run of the same job on the same commit (30202616455) passed. The 06:48 nightly on the preceding commit also passed. It is not a regression from #594/#595/#596.
What the assertion actually tests
After region-b's registrar (the replicator leader) is killed and its mirror expires from etcd-a, cluster a must lose reachability to echo in b. The registry half works reliably — the mirror expired at 0s, exactly as the origin-heartbeat lease design intends, and b's origin data correctly persisted. What is flaky is the data path outliving the registry state.
e2e/multicluster_replicator.sh:374-379 allows 6 attempts × 5s ≈ 30s for the call to stop returning 200.
Why 30s should already be enough — and why that makes this worth investigating
The withdrawal chain is: mirror lease lapses → a's registrar notices → snapshot update → broadcast to agents → agent xDS push → Envoy EDS drops the endpoint.
The registrar's poll interval is 5s (registrar/internal/cmd/config.go:11 defaultSyncInterval). So the dominant term is ~5s plus xDS propagation, comfortably inside the 30s budget. The fact that it occasionally exceeds 30s suggests one of:
- an intermittent stall somewhere in the withdrawal chain (registrar sync, broadcast, or xDS push) — a real product-behaviour question, since endpoint withdrawal latency matters for cross-cluster failover;
- Envoy retaining the endpoint after an empty/updated EDS response longer than expected;
- simply an under-budgeted window that is usually fine.
Distinguishing (1)/(2) from (3) is the point — a negative assertion that flakes can hide a genuine intermittent delay, and "just extend the timeout" would bury it.
Suggested fix
Follow the pattern that paid off in #590: make the failure self-explaining rather than just more patient.
- On failure, dump the state of each link: a's registrar snapshot for
echo, the agent's xDS/EDS view, and Envoy's endpoint state for the cluster — so the next red run names the stalled hop instead of costing a bisect. - Then, if the diagnostics show the chain is simply slower than 30s in the tail, widen the window with justification rather than arbitrarily.
Related: #554 (the other flaky test, since fixed — same principle: triage the mechanism before adjusting the test).
Activity
bpalermo commentedon Jul 26, 2026
Correction: the propagation path is watch-speed, not 5s poll — which makes this anomaly ~2 orders of magnitude worse than first stated
The original write-up said a ~30s budget "should be ample because the registrar polls every 5s (
defaultSyncInterval)". That understates the problem. Reading the implementation:The registrar is push-driven end to end.
registrar/internal/server/sync.go:86-127): the syncer selects on a 5s ticker, a watch-change channel, and a debounce timer. The etcd backend implementsregistry.ChangeNotifierthrough a realclientv3.Watchover the key prefix (registry/internal/etcd/etcd.go:190-215), coalescing into a size-1 buffered channel. It logs this at startup: "registry supports change notifications; syncing at watch speed (poll is backstop)".registrar/internal/replicator/replicator.go:280): leader-elected, watches its OWN authoritative subtree withWithRequireLeaderand replays changes verbatim (Put→Put, Delete→Delete) into each peer's etcd, after an initial full sync — sync-then-watch.So
defaultSyncInterval = 5sis not the propagation path. It is a backstop for windows where a watch is legitimately unavailable (compaction, leader change, re-establish after a broken channel).Expected withdrawal latency is therefore sub-second plus debounce — not ~5s. A call still returning 200 30 seconds after the mirror expired is roughly two orders of magnitude outside the designed path, not a marginal overrun of a tight budget.
What that implies
"Just widen the window" is now clearly the wrong first move — it would paper over one of three materially different bugs:
(3) would be the most significant: it would mean cross-cluster failover latency is bounded by something other than the registry, which is the whole premise of the origin-heartbeat lease design.
Revised fix
Unchanged in shape, sharper in target — instrument the hops, then decide:
echo, the agent's xDS/EDS view, and Envoy's endpoint state for that cluster, so the next red run names which of (1)/(2)/(3) it was;This is the same approach that turned three nights of blind
curl 000into a same-run diagnosis in #589/#590.[-]flaky: replicator e2e — 'client(a) still reaches echo after region-b mirror expired' (intermittent)[/-][+]flaky: replicator e2e — endpoint withdrawal >30s when the designed path is watch-speed (sub-second)[/+]test(e2e): name the stalled hop when the replicator failover assertio…
fix(replicator): bound LeaseGrant on the peer, batch syncFull puts-be…
bpalermo commentedon Sep 20, 2026
Two months on, here is the rate — which turns "intermittent" into something decidable.
Replicator outcome across the last 19 nightly/dispatch e2e runs:
And the decisive datum: 09-17 and 09-18 built the SAME commit,
0459c2a4— one passed, one failed. Identical bytes, opposite outcomes, 24 hours apart. That confirms at a larger scale what the original report established by re-running a single job: this is not a code regression and no commit bisect will find it.But it is also not scattered the way a coin-flip would be. Sixteen clean runs, then exactly two consecutive failures, then clean again, is a clustered flake — which points at an environmental or timing factor that was present on 09-18 and 09-19 and is not now, rather than at a constant low probability.
What this changes about the issue
It should stop being observed and start being measured. Watching further nightlies cannot distinguish the two hypotheses in the original report — an intermittent stall in the withdrawal chain versus a 30 s budget that is simply too tight for the real latency distribution — because both produce exactly this pattern.
The missing number is the withdrawal latency itself. The designed path is registrar poll (5 s,
defaultSyncInterval) → snapshot → broadcast → agent xDS push → Envoy EDS drop. Nobody has recorded how long that actually takes, so "occasionally exceeds 30 s" is measured against an assumption rather than a distribution.Concrete next step: instrument the harness to record the elapsed time from mirror-lease lapse to the first non-200, on every run including the passing ones, and emit it in the job output. Twenty runs of that gives a distribution. If the passing runs cluster at 5–8 s the 30 s budget is generous and the failures are a genuine stall worth chasing in the product; if they cluster at 20–25 s the budget is the bug and the fix is to widen it and say why.
Either way the issue closes on evidence instead of on someone deciding it has been open long enough. Until that instrumentation exists, further nightly observations add nothing.
bpalermo commentedon Sep 20, 2026
The answer is already in the two red runs' own logs — and it is neither of the two hypotheses
I went to instrument this and found I did not have to: the diagnostics
dump_failover_state()added are in the 09-18 and 09-19 job logs, and combined with the registrar's own timestamps they reconstruct the whole sequence to the millisecond. The mesh withdrew the endpoint in ~150 ms. The harness started its 30 s stopwatch 29.4 s before the event it claims to measure.So I was wrong in my last comment, and the framing in the issue body is wrong too. There is a third hypothesis and it is the right one:
The 09-18 timeline (run 35327176927, job 105543522314)
b's registrar to 0kubectl wait --for=deletereturnssync detected changes version=28 events=2— off the 5 s grid, i.e. debounce/watch-driven, +9 msserver/sync.go:189service disappeared from registry; retaining empty cluster/vhost for grace period 1m30s— +150 mscache/cluster.go:606post-dump recheck: client(a) -> echo = 000The inference on the revoke time is not a guess.
DefaultLeaseTTLSeconds = 30(registrar/internal/replicator/lease.go:16). The pod was gone at ~09:05:47.87. The registrar's first detection is at 09:06:17.879 — pod death + 30.00 s, to the millisecond, and it arrives off the poll grid, which means theclientv3watch delivered it, not the backstop. There is no reading of that coincidence other than "the lease revoked right then".Which means the keys were still in etcd-a at 09:05:48.46, when
mirror_presentsaid they were not. That read returned empty for a reason that had nothing to do with the lease:2>/dev/nullplusgrep -q .makes a faileddocker exec, an etcdctl dial timeout, or a command timeout indistinguishable from success-with-no-keys. The pipeline's exit status is grep's; etcdctl's is discarded. On a contendedubuntu-latestrunner carrying two kind clusters, two SPIRE installs and two etcds, that read hiccuping once is entirely ordinary — and one hiccup is all it takes, because the loopbreaks on the first false.09-19 (job 105870909512) is the same shape: declared expiry at 08:54:54.59, six no-op sync cycles on the
*.910grid, thensync detected changesat 08:55:03.213 — again off-grid, again watch-driven — andpost-dump recheck = 503.Three further things the logs settle
1. Both "failures" are near-misses that had already withdrawn.
post-dump recheck: client(a) -> echo = 000(09-18) and= 503(09-19). The call stopped. There was never a stall. Hypothesis (a) is dead.2. The Envoy section of
dump_failover_state()is a vacuous gate. It runsgrep -i echo | head -40over/clusters, then prints^ cause (3): Envoy STILL holds echo hosts after the registry withdrew. In/clusterstext output the per-host rows come after each cluster's config/stat rows. There are threeechoclusters (:8080, bare,:18081) at ~15 config rows each = 45 rows, sohead -40is structurally incapable of reaching a single host row — and in the 09-18 dump it did not: zero::hostname::/::health_flags::/::cx_active::lines, yet the conclusion was printed anyway. Same defect indump_echo_eds(). This is the same class as #853: a check that can only ever emit one verdict.3. Cause (3) is impossible by construction anyway. I traced the consumer side: a removed endpoint is omitted from the CLA entirely (
agent/internal/xds/cache/cluster.go:459buildHTTPEndpointBuckets— full rebuild from the registry listing,cluster.go:221-226), every mesh EDS cluster setshealthy_panic_threshold = 0(agent/internal/xds/proxy/egress.go:264,:337,:378),ignore_health_on_host_removal = true(egress.go:302) andclose_connections_on_host_health_failure = true(egress.go:286). The only retention isdefaultServiceRetentionGrace = 90s(cluster.go:619), which holds an empty CLA — that is the 503, not stale routing. Registrar→agent→Envoy is one 250 ms trailing debounce (agent/internal/xds/server/refresh.go:20) plus RTT.The plan
P1 — make the etcd read fail loudly (this is the fix).
mirror_presentmust return three states, not two, and step 3 must never treat "could not read" as "gone":Step 3's expiry loop keeps polling on
2; steps 1 and 4 already retry, so they are unaffected. The stderr line alone would have named this in one red run.P2 — confirm the expiry before starting the clock. Require two consecutive absent reads ≥1 s apart, and refuse to start the budget earlier than the lease can physically lapse: the mirror cannot be gone before
T_origin_death, and a declaration atT_scale + 31 swhenLEASE_TTL=30and the pod took ~30 s to terminate is arithmetically impossible. Emit a loud warning whenT_declared − T_pod_gone < LEASE_TTL − keepalive_periodand re-read rather than proceed. Cheap, and it catches exactly both red runs.P3 — measure the withdrawal, on every run, with one exec. Replace the 6×5 s
client_codeloop. Its granularity is{0,5,10,15,20,25}and each probe carries ~1.1 s ofkubectl execoverhead, so it cannot produce a distribution. Run the sampler inside the client pod instead — one exec, no per-probe overhead, sub-second resolution, and it reports on pass and fail:with
WITHDRAW_CAP=120≫ the 30 s budget, so a failing run reports how far past rather than only past. That single bit — "31 s" vs "never" — discriminates (a) from (b) on one red run, without needing twenty. Tee theAETHER_METRICline into$GITHUB_STEP_SUMMARYin.github/workflows/e2e.yamlso it is visible without opening the log.Also emit
lease_lapse_seconds(scale-to-0 → confirmed expiry). That is the variable that actually moved across runs, and it is pod-termination-grace + TTL, i.e. nothing to do with the mesh:The four cleanest passes sit at ~61.5 s = 30 s grace + 30 s TTL, exactly as designed. Both failures are the two earliest declarations. (09-12/09-15 are early too and passed, because their probe loop happened to run past the real lapse — which is precisely the coin-flip this produces.)
P4 — fix the vacuous Envoy dump. Filter to host rows and only print the cause-(3) verdict if one actually matched:
P5 — close the false-pass path in
client_code. The assertion is[ "$code" != "200" ], andclient_codereturns000on any failure including a failedkubectl exec. A broken exec is therefore an automatic pass of step 3. It is not what happened here (the post-dump rechecks corroborate real withdrawal), but it is live. P3's in-pod sampler removes the exec from the probe path entirely; additionally assert the code is one of503/000and record which, since503means "Envoy has the cluster with an empty CLA" and000means "the name stopped resolving" — two different correct outcomes that are worth telling apart.What each hypothesis now predicts, numerically
replicator_withdraw_secondsis bimodal with a tail pinned atCAP(120). Already contradicted: both red runs' post-dump recheck was non-200 within ~2–4 s of the die.replicator_withdraw_secondsis sub-second on every run, and all the run-to-run variance moves intolease_lapse_seconds(31–62 s). This is the prediction to try to falsify.I am not proposing to widen the 30 s budget, and after P1–P3 it should be reduced, not raised: measured end-to-end is ~150 ms, so 10 s is already ~60× headroom and a budget that large stops being an assertion. What would justify widening instead:
replicator_withdraw_secondslanding repeatedly in the 20–35 s band with a correctly anchored t=0 — i.e. (b) turning out to be true after all.Harness non-determinism, for the record
runs-on: ubuntu-latest— shared GitHub-hosted runner carrying two kind clusters, two SPIRE installs and two etcd containers. Everydocker exec/kubectl execin the harness is exposed to that contention;mirror_presentis the only one where a hiccup silently changes the verdict.kubectl wait --for=delete pod --timeout=90s ... || true(line ~528) — its return time is t=0 for everything downstream, it varies with termination grace, and a timeout is swallowed by|| true.oklines in these jobs show 66 ms gaps around adocker execthat cannot run that fast, so sub-second deltas inferred from the job log are not trustworthy — another reason the number has to be measured explicitly rather than read off timestamps.✓ inotify limits raised, andraise_inotify()ran before any cluster creation. Ruling it out rather than leaving it on the list.e2e/certsis regenerated per run (generating throwaway CA) — adds time, changes nothing about step 3.Closing criterion
#597 closes when P1–P4 are merged and five consecutive nightlies print
AETHER_METRIC replicator_withdraw_secondswith a sub-second value — i.e. the suite is asserting on a number it actually measured, from a t=0 it actually confirmed. If any of those five prints a value near or above the budget, the metric names which hypothesis survived and the issue re-opens with evidence instead of a re-run.fix(e2e): stop treating a failed etcd read as "the mirror expired" (#597