Skip to content

test(mcpx): env cleanup waits for its daemons to actually exit - #16821

Merged
dezren39 merged 1 commit into
mainfrom
xaltha/13481-cleanup-wait
Nov 29, 2026
Merged

dezren39 merged 1 commit into
mainfrom
xaltha/13481-cleanup-wait

Conversation

@developing-today-fleet

@developing-today-fleet developing-today-fleet Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Refs #13481 slice 3. Diagnosis, change and verification details are in the branch commit f071eae and will be mirrored here once created; full body follows in a comment. Verification: fleet-command run 46271829479 at exact head (guard test -count=5 -race -shuffle=on + TestStopAllShutsEverythingDown), pending the runner pool.


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

mcpx stop returns once a daemon stops answering, but the process exits
later — settle, cache save, pool drain — and under full-suite load that
tail runs past the fixed grace callers allow, so daemons outlived their
tests (#13481: pids still alive after cleanup in a full-suite run, while
the sharded nightly passes the same test in 15.55s).

newEnv's cleanup now snapshots the daemons recorded in the env's own
state directory before stopping, and after stop --all and
StopSupervisors it polls until every one of them is actually gone —
process dead and socket refusing — bounded at 30s. A daemon past the
bound is reported as a leak with its pid and the stop output, attributed
to the owning test instead of being found hours later.

Refs #13481
@coderabbitai

coderabbitai Bot commented Nov 29, 2026

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c2b3c7e1-354d-4211-97b4-24f5ce18c170

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@developing-today-fleet

Copy link
Copy Markdown
Contributor Author

Diagnosis

The failure is a convergence gap, not a stop-path defect:

  • stop --all → per-daemon Shutdown → waitUntilStopped returns when the daemon stops answering. The daemon process exits later: settle, SaveCache/SaveSessions, HTTP drain, pool drain. Env cleanup returned at that point, so anything checking afterwards raced the exit tail.
  • Evidence triangulation: the 2026-11-28 scheduled mcpx-test run on main (46164155049) shows this test passing in its shard in 15.55s (shard-1 timings artifact, parsed firsthand), while the full-suite standard-image run measured for mcpx: full-suite health on main blocks #8465 close condition (conformance/daemon/defaults/e2e/execsvc/sdnotify) #13481 found both daemon pids alive after cleanup. Same code, different load — the exit tail stretches past the test's fixed 10s grace under load.
  • Static audit of the stop path (stopAll/allDaemons/PruneStale/ListDaemons, handleShutdown → self-SIGTERM → Serve → shutdown()) found it sound; nothing to fix there.

Change

One file, pkgs/mcpx/internal/e2e/e2e_test.go (the harness, which is what the guard test tests):

  • newEnv's cleanup snapshots the daemons recorded in the env's own state directory (pid + socket) before stopping.
  • After stop --all and StopSupervisors, cleanup polls every 100ms until each snapshotted daemon is actually gone (process dead and socket refusing), bounded at 30s (cleanupWaitBound).
  • A daemon past the bound is a leak: cleanup fails with its pid/socket and the captured stop --all output, attributed to the owning test — the silent-teardown failure mode the harness already calls out as how the original leak went unnoticed.

Every env in the suite gets the stronger cleanup, not just the guard test's env. TestEnvCleanupStopsTheDaemonItStarted stands as the regression test: it failed in the measured full-suite context and its post-cleanup checks now measure a cleanup that has already converged.

Verification

  • fleet-command run 46271829479 at exact head f071eae: guard test -count=5 -race -shuffle=on (the repo's flake regimen for changed tests) + TestStopAllShutsEverythingDown — pending the stalled runner pool; merge on green.
  • Control: mcpx-test run 46270538777 (sharded suite, unmodified main) queued as the passing-context baseline.

(Lane 0647-L14R; PR created via the REST route because GraphQL createPullRequest is secondary-rate-limited fleet-wide right now.)

@dezren39
dezren39 merged commit 90d1fc1 into main Nov 29, 2026
2 checks passed
@dezren39
dezren39 deleted the xaltha/13481-cleanup-wait branch November 29, 2026 14:34
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