Repository navigation
Description
Summary
The spored systemd unit sets PrivateTmp=true. systemd then gives the daemon a private /tmp namespace, so the completion file the rest of the system writes to the real /tmp/SPAWN_COMPLETE is invisible to spored. Its os.Stat("/tmp/SPAWN_COMPLETE") looks inside the private mount, never sees the file, and --on-complete (stop/terminate/hibernate) + --pre-stop based on the completion signal never fire.
This is the second half of why Tier 2 pre-stop / on-complete failed (the first half was #65, the monitor loop never running). Even with #65 fixed and the monitor ticking every minute, completion was never detected.
The completion contract requires a shared /tmp
The default completion file is /tmp/SPAWN_COMPLETE (pkg/provider tag default, spored status shows it). It is written by:
- end users over SSH (
touch /tmp/SPAWN_COMPLETE) spawn connect <name> -- "touch /tmp/SPAWN_COMPLETE"- nf-spawn task wrappers writing the completion sentinel
- any in-instance workload signaling done
All of those write the host /tmp. With PrivateTmp=true, spored cannot see any of them.
Reproduction (real AWS, confirmed 2026-06-06)
t3.small, --on-complete stop --pre-stop "touch /tmp/prestop-ran.txt", monitor fix (#65) applied so the loop ticks every minute:
touch /tmp/SPAWN_COMPLETEover SSH → 11 monitor ticks pass, no "Completion signal detected", instance stays running, no pre-stop file.sudo systemctl show spored -p PrivateTmp→PrivateTmp=yes.ls /proc/$(MainPID)/root/tmp/SPAWN_COMPLETE→ No such file (daemon's private tmp), while real/tmp/SPAWN_COMPLETEexists.- Touch the file inside the daemon's private tmp (
/proc/$PID/root/tmp/SPAWN_COMPLETE) → next tick detects completion → pre-stop runs → instance stops. ✅
That last step is the smoking gun: completion logic works; the daemon was simply looking in the wrong /tmp.
Fix
Remove PrivateTmp=true from the spored systemd unit. spored is a root daemon whose entire purpose is watching a host-side file and managing the instance; an isolated /tmp provides negligible hardening while silently breaking the product's core lifecycle contract.
Three unit definitions carry it:
scripts/spored.service:20scripts/install-spored.sh:107cmd/launch.go:2392(inline heredoc baked into user-data)
(If any /tmp isolation is ever wanted later, it must be paired with a BindPaths=/tmp or a documented non-/tmp completion-file default — but the simplest correct fix is to drop PrivateTmp.)
Severity
CRITICAL. Combined with #65, completion-driven auto-stop/terminate has been completely non-functional for the default path. Instances that rely on --on-complete to shut themselves down run until TTL (or forever, pre-#65) — the exact unbounded-cost failure this product exists to prevent.
Related
- CRITICAL: spored monitor loop never runs after startup — TTL/idle/on-complete/pre-stop all silently dead #65 (monitor loop never runs) — sibling root cause, found in the same investigation
- Tier 2: triage 7 remaining failures (post-#56 harness fix) #61 (Tier 2 failures) — pre-stop/on-complete e2e gaps these two bugs explain
Activity
scttfrdmn commentedon Jun 6, 2026
Fixed in #67 (together with #65). Confirmed end-to-end on real AWS via the real user path:
spawn connect spore66-validate -- "touch /tmp/SPAWN_COMPLETE"→ withPrivateTmpremoved (PrivateTmp=no), the daemon detected the host file at the next tick:Removed
PrivateTmp=truefrom all three unit definitions (scripts/spored.service, scripts/install-spored.sh, cmd/launch.go).TestSporedUnit_NoPrivateTmpguards against reintroduction.fix(spored): keep lifecycle monitor alive + let it see /tmp completion (
test(agent): guard --on-complete fires regardless of job origin (#105) (
fix(task): flush a completion record and the log when a lifecycle lim…