Skip to content

fix(soak): the prober grade reads raw counters and gates the unpinned-cluster counter; churn.sh stops on TERM and leaves no orphan (#1390, #1418, #1419, #1423) - #1458

Merged
bpalermo merged 8 commits into
mainfrom
fix/soak-grade-churn-1390
Oct 8, 2026

Conversation

@bpalermo

@bpalermo bpalermo commented Oct 8, 2026 •

Copy link
Copy Markdown
Owner

Closes #1390
Closes #1423
Closes #1419
Closes #1418

This is the harness half of a six-issue task. The six did not fit one reviewable pull request, so the prober's failure line (#1391) and the test workloads' stdout (#1395) are in a second one, #1461. The two do not depend on each other.

What changes

e2e/soak/prober-grade.sh (new): the prober grade, from raw counters (#1390).
e2e/soak/prober-grade.sh --dir <run dir> --prometheus <URL> (or --prometheus-service <ns>/<svc>:<port>, through the API server with the run's own context). The endpoint is a parameter and has no default.

  • T0 is the churn driver's start line in the run's churn.log, the window 8 h. An e2e run has no churn log: T_LOAD + DURATION_S of run.env.
  • Four instant queries, printed with the time each was evaluated at: each metric at T0, and metric[<window>s] at the window's end, which returns the raw samples.
  • Per series the count is the sum of the steps between samples, starting from the value at T0. A series absent at T0 starts from 0. A sample below the one before it is a reset: the new value is counted whole and the reset is printed. A prober pod replaced mid-run is counted up to its last sample.
  • Output: totals per tier and result with the success rate as the control, every non-success per tier, result and source node, each series born in the window, each reset, the pod set, a PROBER verdict= line and one VERDICT line. Exit 0 pass, 1 something to attribute, 2 unproven; 2 comes first, so a FAIL beside a count that cannot be trusted is exit 2.
  • --logs-file or --logs-url adds the cross-check against AETHER_PROBE_FAIL lines (detail lines plus the suppressed counts). A suppressed summary carries the time its minute was closed, up to two minutes after the failures it counts; one closed within two minutes after either end of the window is printed as a boundary summary, left out of the sum, and the row is UNPROVEN when the counters lie between the two sums.

The unpinned-cluster gate (#1423), in the same grade and by the same computation: aether_agent_identity_cluster_unpinned_total must not move. UNPINNED verdict= is its own line. The counter is seeded at zero, so no series at all is UNPROVEN.

churn.sh stops on TERM and leaves nothing (#1419). It did not have the sleep & / PID / wait pattern. It had a foreground sleep, and bash runs a trap only when the foreground child has ended, so a TERM took effect at the next roll: up to 12 minutes later, 90 in the no-roll window. Looking for what a stop leaves found more:

what before now
TERM between rolls honoured when the sleep ended within 2 s: the wait is read -t on a private fifo, no child
a queued RSS sampler survived the driver (a subshell around sleep 1680, then around the sampler) one process, stopped by the driver; the sampler traps TERM
the uds-csi step's kubectl get pods -w left running after every step, stopped or not: the kill reached the subshell around it exec'd, so the kill reaches kubectl
TERM during the pre-flight killed the shell, left the kubectl call early trap, the call is waited for
TERM during a TRIPLE the three rolls' kubectl calls left behind the rolls ignore TERM and are waited for
TERM during the new-SA node listing call left behind (mapfile < <(...) is not waited for) a command substitution

A stop is now one pass: restore the SHRINK and delete the new-SA objects, stop the children, exit 143. It never exits ahead of a child: a call that does not return holds the driver, and after 20 s the log names what it is waiting for.

lib-wait.sh (new): the clock and the wait without a child process, shared by churn.sh, restart-watch.sh and sample-proxy-rss.sh. restart-watch.sh's own copy (from #1417) moved there unchanged.

#1418. The timestamps of churn.sh's log and of the watchdog, and the waits, no longer use a command substitution (printf '%(…)T'). The kubectl calls still do, so the README now says: send TERM until the script has exited.

What it does to a cluster is unchanged

The before/after of a dry run, whole schedule, fake kubectl, on a clock the test controls:

before (origin/main churn.sh):  118 kubectl calls, 105 log lines, 6 sampler runs
after  (this branch):           118 kubectl calls, 105 log lines, 6 sampler runs
calls (second after T0 + arguments), sorted:  identical (sha256 e54632b4…: main's driver, this branch's, and the committed file)
churn.log, sorted:                            identical (sha256 2a94e95c… both)
calls per minute offset: 42@0 1@12 1@24 1@36 1@48 1@60 1@72 1@84 1@96 1@108 1@120 4@126 [email protected] 1@132 1@144 1@156 13@162 [email protected] 1@168 … 3@300 1@312 1@324 1@336 1@348 1@360 2@450 [email protected]

The call-list line was measured again at the end of the review, by running the test's dry run once with origin/main's churn.sh and once with this branch's and comparing both with the committed file; the log-line and sampler counts are from the first measurement. The "before" call list is committed as testdata/churn/schedule.tsv and the test holds every later run against it. One difference that is not in the schedule: the old run ended with two kubectl get pods -w still running, the new one with none.

One behaviour that does change: SOAK_SHRINK_SECONDS and SOAK_PROXY_RSS_DELAY were arguments to sleep and so also took 90s or 1.5. They are now clock arithmetic, and anything but whole seconds is refused at pre-flight (exit 2, before T0).

Evidence

Measured:

  • The grade against a real Prometheus (read-only, a test cluster, through the API-server proxy) for the run in soak: grading the prober with increase() loses the first sample of a series born inside the window (37 reported, 40 real) #1390: TOTAL tier=mesh_dns result=timeout count=40, two BORN lines with first=2 and first=1 (21 + 19). That is the 40 of the issue, and 37 is what is left when the two creating samples are not counted. The same run's unpinned counter reads 2,594 over five nodes with two resets per node at the two agent rolls. That run was on a chart from before fix(agent): the unpinned-cluster report leaves out the plaintext UDP floor (#1393) #1421, so that number is the old noise, not a finding.
  • Red, then green, in //e2e/soak:harness_test:
    • on the canned born fixture, last-minus-first-sample (how increase() counts) reads 37, the script 40; x - x offset 8h drops both series;
    • against origin/main's churn.sh, the new tests fail: TERM while it waits for the first roll gives exit 137 after the test's 10 s timeout with sleep 720 left; a finished dry run leaves two watches; the sweep finds the watch left at every boundary of the uds-csi step; every pre-flight call and each TRIPLE roll is "NOT waited for";
    • with the fix: a TERM before each of ~445 commands (one per code point; a full run, --new-sa-once, --uds-csi-once, with and without a queued sampler) and during each of 65 kubectl calls: exit 143, nothing left in the session, the clock does not move on.
  • Mutations, each on a copy, each caught: sampler not exec'd; no stop_children; a TRIPLE roll that does not ignore TERM; foreground sleep again; the watch as k … & again; the mapfile process substitution again; no trap in the sampler; one TERM to a child instead of until it is gone; no early trap; a roll moved by one minute (caught by the schedule). Nine mutations of prober-grade.sh, each caught (absent series started from its first sample; reset not handled; baseline ignored; no series read as a pass; a failed query read as no data; log lines outside the window; suppressed not added; an unpinned increase passing; the window not checked against now).
  • TZ=UTC printf '%(%FT%TZ)T' gives UTC with the environment's zone three hours off on bash 4.2.53, 4.4.23 and 5.2.21 (containers for the first two). The scripts state bash 4.2+.
  • bazel test //e2e/... //scripts/... //bazel/actionlint:all, bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //..., make format-check, scripts/check-shell-lint.sh: all pass. The harness test takes about 50 s on a 20-core machine and 85 to 92 s pinned to two cores (five runs in a row with the final code, all green). Its Bazel timeout stays moderate (300 s). After the review changes: 45 to 48 s under Bazel, 72 s pinned to four cores, 359 assertions.

The failed test check, and the review

The first run's test job failed for a real reason, in this change's own new test (ci is the aggregate and failed only because test did): churn term sweep: … udscsi, TERM before command 277, exit 0; no TERM was sent. The sweep sent its TERM before "the k-th command" of a traced run. The uds-csi step polls for another process and goes round a loop a number of times that depends on the machine (271 and 283 commands in two runs on one machine), so the 277th command of the trace was past the end of a shorter run. A TERM point is now the code point itself (line, command, and whether a sampler has been queued). A traced point that a run does not come to again in three tries is listed apart and bounded at 12; in every run since, there were none.

From review, each with a test that fails without the fix:

  • stop_children gave up after 20 s and let the driver exit ahead of a child. It now returns only when no child is left. Test: the TRIPLE's three rolls are made to hang until the driver says it is waiting; the fake then checks the driver is still there. With the bound put back: the driver was GONE when the rolls returned.
  • The boundary suppressed summary (above). With the old selection put back, six assertions fail.
  • Exit 2 before exit 1 (above). Before: exit 1 with logs=MISMATCH.
  • The test's timeout is moderate again, as this description said.

Inferred, not measured:

  • That a real kubectl get pods -w was left running by the old driver on a real cluster. The test shows the mechanism with a fake kubectl (killing $! of k … & kills a bash subshell, not its child); I did not look for leftover processes from a past soak.
  • The 20 s after which stop_children says what it is waiting for is a choice, not a measurement.

Not verified:

  • --logs-url against a live log store. The request shape (/select/logsql/query with query, start, end) is from VictoriaLogs' documentation as I remember it; only --logs-file and a canned response are tested.
  • --prometheus URL against a live endpoint (the --prometheus-service form is the one that was run for real).
  • Nothing was run against a cluster other than those read-only queries. A real soak with the changed driver has not been run.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

…-cluster counter; churn.sh stops on TERM and leaves no orphan (#1390, #1418, #1419, #1423)

prober-grade.sh (#1390, #1423). The soak grade read
increase(aether_probe_requests_total{result!="success"}[8h]), which cannot
count the sample that creates a series: 37 reported for a run whose raw
counters read 40. The new script takes the value of every series at the
window's start (absent = 0) and every raw sample in the window, and sums the
steps: a series born in the window is counted whole, a counter reset is
counted across and printed, a prober pod replaced mid-run is counted up to
its last sample. It prints the window, the four queries, totals, every
non-success by tier, result and source node, and one verdict line. The same
computation over aether_agent_identity_cluster_unpinned_total is the new
unpinned-cluster gate: any increase fails, no series is UNPROVEN. The
Prometheus endpoint is a parameter (a URL, or a Service through the API
server); there is no default. A log file or a log endpoint adds the
cross-check against AETHER_PROBE_FAIL lines.

churn.sh (#1419). It slept in the foreground, and bash runs a trap only when
the foreground child has ended: a TERM took effect at the next roll, up to
12 minutes later, 90 in the no-roll window. It did not have the
sleep-in-background pattern of the old watchdog, but it left other things: a
queued RSS sampler survived a stop, each uds-csi step left its `kubectl get
pods -w` running even on a run that finished (the kill reached the subshell
around it), and a TERM in the pre-flight, in a TRIPLE or in the new-SA node
listing left a kubectl call behind. It now waits without a child process
(lib-wait.sh, shared with restart-watch.sh and sample-proxy-rss.sh), and a
stop is one pass: the cluster first (SHRINK, new-SA objects), then its own
children, then exit 143. What it does to the cluster, and when, is
unchanged: every kubectl call of a dry run and the second it is made at are
held against a schedule written by the script as it was.

#1418. No `$(date)` is left in the log line, the waits or the watchdog's
sample loop: the time is printf's %(...)T. bash can still drop a TERM that
lands in the `$(...)` around a kubectl call, so the README says to send TERM
until the script has exited.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
Copilot AI balanced review requested due to automatic review settings October 8, 2026 16:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Log-boundary accounting, exit-status precedence, and bounded child cleanup can produce incorrect grading or leave processes running.

3 open findings
What changed in this PR

Adds reliable raw-counter grading and improves soak-process shutdown behavior.

Changes:

  • Adds prober and unpinned-cluster grading from raw Prometheus samples.
  • Introduces shared interruptible wait utilities.
  • Expands harness coverage for grading, churn schedules, and termination.
File Description
e2e/​soak/​BUILD.bazel Registers scripts, fixtures, and expanded harness timeout.
e2e/​soak/​README.md Documents grading and shutdown behavior.
e2e/​soak/​churn.sh Adds interruptible waits and child cleanup.
e2e/​soak/​harness_test.sh Tests grading, schedules, and termination.
e2e/​soak/​lib-wait.sh Provides fork-free clock and wait helpers.
e2e/​soak/​prober-grade.sh Implements raw-counter grading and log cross-checks.
e2e/​soak/​restart-watch.sh Uses shared wait and timestamp helpers.
e2e/​soak/​sample-proxy-rss.sh Adds signal handling and safer subprocess waits.
e2e/​soak/​testdata/​churn/​schedule.tsv Captures the expected churn schedule.
e2e/​soak/​testdata/​prober-grade/​born/​logs.jsonl Adds VictoriaLogs response fixture.
e2e/​soak/​testdata/​prober-grade/​born/​probe.start.json Adds born-series baseline fixture.
e2e/​soak/​testdata/​prober-grade/​born/​probe.window.json Adds born-series window fixture.
e2e/​soak/​testdata/​prober-grade/​born/​prober.log Adds failure-log fixture.
e2e/​soak/​testdata/​prober-grade/​born/​unpinned.start.json Adds unpinned baseline fixture.
e2e/​soak/​testdata/​prober-grade/​born/​unpinned.window.json Adds unpinned window fixture.
e2e/​soak/​testdata/​prober-grade/​clean/​probe.start.json Adds clean baseline fixture.
e2e/​soak/​testdata/​prober-grade/​clean/​probe.window.json Adds clean window fixture.
e2e/​soak/​testdata/​prober-grade/​clean/​unpinned.start.json Adds clean unpinned baseline.
e2e/​soak/​testdata/​prober-grade/​clean/​unpinned.window.json Adds clean unpinned window.
e2e/​soak/​testdata/​prober-grade/​empty/​probe.start.json Adds absent-metric baseline fixture.
e2e/​soak/​testdata/​prober-grade/​empty/​probe.window.json Adds absent-metric window fixture.
e2e/​soak/​testdata/​prober-grade/​empty/​unpinned.start.json Adds absent-unpinned baseline.
e2e/​soak/​testdata/​prober-grade/​empty/​unpinned.window.json Adds absent-unpinned window.
e2e/​soak/​testdata/​prober-grade/​reset/​probe.start.json Adds reset baseline fixture.
e2e/​soak/​testdata/​prober-grade/​reset/​probe.window.json Adds reset and replacement fixture.
e2e/​soak/​testdata/​prober-grade/​reset/​unpinned.start.json Adds reset unpinned baseline.
e2e/​soak/​testdata/​prober-grade/​reset/​unpinned.window.json Adds born unpinned-counter fixture.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread e2e/soak/churn.sh Resolved
Comment thread e2e/soak/BUILD.bazel Resolved
Comment thread e2e/soak/prober-grade.sh Resolved
bpalermo and others added 3 commits October 8, 2026 16:07
…s ahead of a child, and a boundary `suppressed` summary is not a mismatch

The `test` job failed on this branch with
`churn term sweep: ... udscsi, TERM before command 277, exit 0; no TERM was sent`.
The sweep sent its TERM before "the k-th command" of a traced run. The uds-csi
step polls for another process and goes round a loop a number of times that
depends on the machine (271 and 283 commands in two runs on one machine), so
the 277th command of the trace was past the end of a shorter run. A TERM point
is now the code point itself: line, command and whether an RSS sampler has
been queued, the first time the main shell comes to it. A traced point that a
run does not come to again (three tries) is listed apart and bounded, instead
of read as a TERM that was mishandled.

From review:

- `stop_children` gave up after 20 s, said `left behind` and let the driver
  exit ahead of a child that was still running, which is what the stop says it
  never does. It now returns only when there is no child left, and names what
  it is waiting for in the log after 20 s, once. Test: the TRIPLE's three
  rolls made to hang past that.
- A `suppressed` summary's `t` is when its window was closed, up to two
  minutes after the failures it counts. One closed within two minutes after
  either end of the run's window is now a boundary summary: printed, left out
  of the sum, and the row is UNPROVEN when the counters lie between the two
  sums. `--logs-url` asks for two minutes past the end.
- `harness_test` keeps its `moderate` timeout, as the description said.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
…the hung rolls return

Without it the test passed on a driver that exited at its bound: the rolls
returned 200 ms later and nothing was left by the time the test looked.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
Copilot AI balanced review requested due to automatic review settings October 8, 2026 19:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Log cross-check failures can return exit 1 instead of the documented unproven exit 2.

1 open finding
3 resolved since last review

🧠 Review effort: Balanced

Comment thread e2e/soak/prober-grade.sh Resolved
From review: with `prober=FAIL`, a log MISMATCH or UNPROVEN still left the
script at exit 1, as if the counters' number were a list to attribute. Exit 2
now comes first; exit 1 is a FAIL with everything else proven.

The script's header also said a failed probe's destination "is on the
AETHER_PROBE_FAIL line". That is #1391, which is not in this change: it now
says it is found through the access logs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
Copilot AI balanced review requested due to automatic review settings October 8, 2026 19:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A TERM during scale-down can exit before recording the replica count, leaving the shrink target at zero.

1 open finding
4 resolved since last review

🧠 Review effort: Balanced

Comment thread e2e/soak/churn.sh Resolved
… replicas

From review: `SHRINK_PREV` was set after the `scale --replicas=0` call. A
TERM that arrived during the call was taken when it returned, with the scale
applied and nothing recorded to restore: the driver exited 143 and left the
target at zero. It is now set before the call.

A scale-down that fails keeps it set as well. A call that timed out may have
been applied, so the abort restores the previous count; restoring a value
that is already there changes nothing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
Copilot AI balanced review requested due to automatic review settings October 8, 2026 20:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Start-only metric series are discarded, allowing incomplete telemetry coverage to be omitted from grading.

2 open findings
1 resolved since last review

🧠 Review effort: Balanced

Comment thread e2e/soak/prober-grade.sh Resolved
Comment thread e2e/soak/README.md Resolved
From review: only the log timestamp and the waits were converted. A step
still reads kubectl output and its deadlines through one while it runs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
Copilot AI balanced review requested due to automatic review settings October 8, 2026 20:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The unresolved grader gap can omit T0-only series, allowing a silent agent to leave the unpinned gate passing.

1 open finding
1 resolved since last review

🧠 Review effort: Balanced

@bpalermo
bpalermo merged commit 1aa8da9 into main Oct 8, 2026
31 checks passed
@bpalermo
bpalermo deleted the fix/soak-grade-churn-1390 branch October 8, 2026 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants