Skip to content

mcpx: zombie-aware liveness for daemon stop checks (#16312) - #17040

Merged
developing-today-fleet[bot] merged 3 commits into
mainfrom
felix/16312-zombie-liveness
Nov 30, 2026
Merged

developing-today-fleet[bot] merged 3 commits into
mainfrom
felix/16312-zombie-liveness

Conversation

@developing-today-fleet

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

Copy link
Copy Markdown
Contributor

Fixes #16312

Root cause

The mcpx daemon's shutdown was never slow: lane 0640-GF's SIGQUIT diagnostic (run 46330420941, verdict on #16312) showed the daemon reaching exit in ~1ms. The "daemon alive 30s after stop" survivor is an unreaped zombie — the daemon is autostarted Setsid + Process.Release by a CLI that exits, so its parent is the container PID 1, which does not reap orphans in the executor; both liveness checks probed with syscall.Kill(pid, 0), which succeeds for zombies:

  • daemon.ProcessAlive (internal/daemon/paths.go), used by the e2e cleanup sweep
  • daemonAlive (internal/e2e/e2e_test.go), used by the post-stop poll, plus a raw signal-0 assertion in TestEnvCleanupStopsTheDaemonItStarted

The same mechanism produced the three "daemon(s) still alive after stop --all" cleanup failures on #8465.

Change (3 commits)

  1. Failing-first tests — TestProcessAliveReadsAZombieAsDead (daemon) and TestDaemonAliveReadsAZombieAsDead (e2e): spawn a child, kill it, do not reap it, require the liveness check to read it as dead. Both failed on the unfixed code (fleet run 46332636235: ProcessAlive(8548) reports a killed, unreaped child (a zombie) as alive; same for daemonAlive).
  2. Fix — the daemon package's test-only processExited helper (from mcpx: TestScriptViewCommandTimeoutKillsSpawnedWorkers fails in Fleet executor containers #13713) is promoted to production: Linux reads /proc/<pid>/stat (state Z = exited), darwin reads kern.proc.pid via golang.org/x/sys/unix (SZOMB), other platforms keep the signal-0 fallback. ProcessAlive consults it after a successful probe (EPERM semantics unchanged); daemonAlive and the cleanup assertion consult e2e's existing exited helper.
  3. Quarantine lift (separable) — removes the mcpx testing: flake policy -- race, shuffle, repeat runs, quarantine with expiry, a second OS #1973 quarantine from TestAddingAServerIsLiveWithoutARestart and TestSecretSetAndUnsetOverTheSocket; if this commit ever needs to go, the fix stands on its own and this PR should reference mcpx: e2e suite hangs intermittently on aarch64-darwin (different test each run; daemon-side, reload path) #16312 instead of closing it.

No new dependencies: golang.org/x/sys was already a direct requirement; the darwin file uses its existing unix.SysctlKinfoProc.

Gate (all at head e769e6b, read from the job logs)

  • Failing-first, tests-only head 2f1a8a6 — run 46332636235: both new tests FAIL with the zombie messages above.
  • Quarantined pair, -race -shuffle=on -count=5 — run 46333433654: 5/5 PASS each, 0 skips, no leak errors.
  • mcpx coverage burn-down: CLI commands (running group) with no integration-test exercise #8465 coverage group, go test ./internal/e2e/ -run TestCoverage -count=1 -v — run 46333440723: 11 run / 11 PASS / 0 fail, including TestCoverageCLIAdapterList (the test that failed on main with the leak error).
  • Units — run 46333446673: full internal/daemon package ok; TestEnvCleanupStopsTheDaemonItStarted, TestExitedTellsALiveProcessFromAGoneOne, TestDaemonAliveReadsAZombieAsDead PASS (zombie test: 0.05s, vs the 5s deadline failure pre-fix).
  • macOS (real darwin execution) — run 46334083521: daemon + e2e zombie/exited tests PASS via the sysctl path; internal/daemon test-compiles clean. (A Linux-executor GOOS=darwin build attempt fails in runtime/cgo — gcc: unrecognized option '-arch' — an executor toolchain limit, not this change; the macOS run is the darwin record.)
  • gofmt -l clean on both packages.

Not in scope: the #16797 restart/attach failure is a different mechanism (0640-FB's slice) and the restart/attach path is untouched. Signal-0 helpers in internal/pool / internal/mcpclient and e2e's processExists answer different questions (foreign-process existence) and are unchanged.

Lane 0640-GS (Felix). Merge is Felix's call.

{
  "direct_parent": null,
  "links": [],
  "lineage": {
    "design": null,
    "roadmap_item": null,
    "priority": null
  },
  "pm_meta": 1,
  "provenance": {
    "queue_id": null,
    "scheduled_start": null,
    "picked_up_at": null,
    "work_started_at": null,
    "created_at": "2026-11-30T01:46:41Z",
    "session_id": null,
    "lane": null,
    "host": "htch-runtime",
    "worktree": "/home/hatch",
    "model": null,
    "lane_start_issues": [],
    "workspace_ref": {
      "kind": "worktree",
      "id": "/home/hatch",
      "repo": "developing-today/code",
      "branch": "main",
      "sha": "010b47d1c4cecdcd1b7d6ea260b7c9b0a61fb89e"
    },
    "auth_subject": "felix",
    "stamped_by": "fleet 0.1.0 (native)"
  }
}

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

Felix added 3 commits November 30, 2026 01:03
ProcessAlive (internal/daemon) and daemonAlive (internal/e2e) probed
with signal 0 only, which reads an unreaped zombie as alive; where
PID 1 does not reap orphans a stopped daemon then reads as alive past
every cleanup bound even though its shutdown completed. Both checks
now treat a zombie as dead: processExited is promoted from the daemon
package's test helpers into production (linux /proc stat, darwin
sysctl, signal-0 fallback elsewhere) and ProcessAlive consults it
after a successful probe; daemonAlive and the cleanup assertion in
TestEnvCleanupStopsTheDaemonItStarted consult e2e's existing exited
helper. EPERM semantics unchanged.
TestAddingAServerIsLiveWithoutARestart and
TestSecretSetAndUnsetOverTheSocket were quarantined under #1973
pending the root cause of their cleanup failures; the zombie-aware
liveness fix in the previous commits is that root cause's fix, so the
exemption is removed rather than left to expire on 2026-12-31. This
commit is separable: if the pair does not pass its gate, the lift is
reverted and the fix references #16312 instead of closing it.
@coderabbitai

coderabbitai Bot commented Nov 30, 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: a9125f76-d365-42de-aff6-c3a3bb264cb8

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

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.

mcpx: e2e suite hangs intermittently on aarch64-darwin (different test each run; daemon-side, reload path)

0 participants