Repository navigation
Description
Severity: critical — breaks the core lifecycle + cost-control guarantee
On a freshly launched instance, spored logs Monitoring started and then nothing ever again — the monitor's per-minute checkAndAct loop never executes. Consequently none of these fire:
- TTL expiry → instance never auto-terminates (the exact uncontrolled-cost scenario e2e Tier 2/3 tests leak instances — cleanup stops instead of terminating, no reaper safety net #47 is meant to prevent, but in production, not just tests)
- idle-timeout → never stops/hibernates
- on-complete → completion signal ignored
- pre-stop → never runs
Evidence (real instance, spawn/spored v0.36.11)
Launched --on-complete stop --completion-delay 5s --pre-stop "touch /tmp/prestop-ran.txt". Full /var/log/spored.log, unchanged across ~10 min and multiple completion triggers:
... 03:48:30 Agent initialized for instance i-...
03:48:30 Config: TTL=20m0s, IdleTimeout=0s, Hibernate=false
03:48:30 ... Monitoring started
03:48:30 EBS hourly cost: $0.0022/hr
Last line is 03:48:30. Touched /tmp/SPAWN_COMPLETE repeatedly; instance stayed running indefinitely; /tmp/prestop-ran.txt never created; checkAndAct's config-refresh (which logs warnings on failure) never logged. Daemon is active (systemctl) — alive but its monitor loop body never runs.
Two corroborating facts:
- The startup
Config:line showsTTL=20mbut no on-complete — the daemon read tags beforespawn:on-completewas visible (eventual consistency). That alone would be handled by the tick-1 config refresh (agent.go:262,configRefreshTick == 1) — except that refresh never runs, which is the real bug. - A separate
spored config listprocess (fresh agent) DOES read on-complete/pre-stop correctly — so tags & parsing are fine; it's specifically the daemon's running monitor that's stuck.
Suspected cause
Agent.Monitor (pkg/agent/agent.go:219): after log.Printf("Monitoring started") (223) and BEFORE the ticker for-loop (245), it calls a.provider.IsSpotInstance(ctx) (228). IsSpotInstance (pkg/provider/ec2.go) does a blocking IMDS GetMetadata("instance-life-cycle") with the daemon's context (no per-call timeout). If that IMDS call hangs (IMDS hop-limit, token, or network), Monitor blocks before ever entering the ticker loop — exactly the observed "logs started, then dead" behavior.
Fix direction
- Give
IsSpotInstance(and the other IMDS calls) a short per-call timeout (e.g.context.WithTimeout(ctx, 5s)) so it can never block startup. On timeout, assume not-spot and proceed. - Better: move the spot-monitor goroutine launch to NOT gate the main ticker loop — start the ticker loop first, decide spot-monitoring asynchronously.
- Add a heartbeat log to
checkAndAct(e.g. trace-level every tick) so a dead loop is observable.
Impact / why critical
An instance whose monitor is dead never auto-terminates on TTL → unbounded cost, the core thing spore.host exists to prevent. Likely also the root cause behind nf-spawn pre-stop/on-complete reports and several Tier 2 e2e failures (#61). The e2e reaper/leak-check only protect the test account — real users have no such safety net.
Context
Found debugging #61 Tier 2 pre-stop failure on real AWS. Reproduces every launch. Needs IMDS-readiness verification on the instance to 100% confirm the IsSpotInstance hang, but the evidence strongly points there.
Activity
scttfrdmn commentedon Jun 6, 2026
Root-caused and fixed in #67. Confirmed on real AWS (spore-host-dev, t3.small):
monitor tick Nheartbeat). Lifecycle loop runs unconditionally;IsSpotInstancenow off the critical path + bounded to 5s.Fix: spot detection/polling moved to its own goroutine so it can't gate the ticker loop;
IsSpotInstance/CheckSpotInterruptionbounded withcontext.WithTimeout(5s); per-tick heartbeat log added. Regression testTestMonitor_SpotDetectionDoesNotGateTickerfails against the old gating code, passes with the fix.Note: a sibling bug #66 (PrivateTmp hid the completion file) had to be fixed too before on-complete/pre-stop actually fired end-to-end.
fix(spored): keep lifecycle monitor alive + let it see /tmp completion (
feat(reaper): server-side TTL reaper backstop + TTL-always-terminate …
feat(spored): mount async-created FSx at runtime (#194 part 1) (#198)
feat: optional fire-and-forget spot-interruption webhook (#228) (#229)
feat(reaper): make failures observable and alarmable (#469) (#471)
Publish and refresh hybrid job-array peers for workloads and spored s…
Publish and refresh hybrid job-array peers for workloads and spored s…
Publish and refresh hybrid job-array peers for workloads and spored s…