fleetd #504 item 1: stop the false ok on the loaded-but-not-running stop path #541
Reference in New Issue
Block a user
Delete Branch "worker/504-failed-reported-clean-3cfd66-3"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Item 1 of fleetd #504 only. Items 2-4 stay open.
Defect: the two
stopbranches for "loaded but not currently running" (launchd/systemd, reached when$OLD_PIDis empty) ranlaunchctl unload/systemctl --user stopwith2>/dev/null || trueand printedokunconditionally. A real supervisor failure (e.g. launchd or the systemd user bus unreachable) read exactly like a harmless already-stopped answer, so the script proceeded to start believing nothing was loaded -- the two-daemons failure fleetd #492 exists to prevent.Fix: two new functions,
unload_launchd_if_loaded/stop_systemd_if_loaded(added right aftersystemd_loaded), apply that function's own pattern to the write side: capture stderr separately into a temp file, and only a non-zero exit WITH stderr content is a real failure (dies with the captured message); a non-zero exit with empty stderr is the genuine already-stopped/unloaded answer and is tolerated. No${VAR:-default}anywhere -- the script runs underset -euo pipefail. The two call sites in the main flow now call these functions instead of the bare|| true.Tests (5 new, scripts/test-redeploy-fleetd.sh): dies-on-real-failure and tolerates-clean-negative for each function (using a stub
launchctl/systemctlfirst on PATH, same technique the existing systemd-probe-error test uses), plus a source-text check that the main flow calls the new functions and the bare2>/dev/null || truedefect has not come back.Verification:
bash scripts/test-redeploy-fleetd.sh: exit 0, anchored^FAIL:count 0 (3 unanchored FAIL: lines are the suite's own internal mutation-cell fixtures, unrelated to this change), endsPASS: redeploy log classifier.bash -nclean under both/bin/bash(3.2.57) andenv bash(5.3.9).comm -3empty (60 baseline + 5 new).|| true. Each mutation made its own test go red with its own message (verified independently for both halves of the call-site test); each was then restored to a byte-identical file (fullshasum -a 256match) and a green control run followed.Never ran redeploy-fleetd.sh itself against the live daemon (per instructions) -- all verification is via bash -n and the sourced test suite.