Repository navigation
Description
Why
#65 proved the structural weakness: TTL is not independent machinery. TTL expiry is a branch inside checkAndAct(), inside the in-instance monitor loop (pkg/agent/agent.go:299 → a.terminate("TTL expired")). When #65 stopped that loop from running, it killed TTL, idle, cost, on-complete, and pre-stop all at once — and 5 real instances ran 11–15 days past a 10-minute TTL (confirmed State: running, full compute, in spore-host-dev). They were the in-the-wild casualties.
Lifetime is currently enforced from inside the instance, by the very thing whose failure is unobservable from outside. That's the inversion to fix. The project invariant should be: a spore can never outlive its spawn:ttl-deadline, regardless of spored's health. ("…everything dies, eventually.")
What
An out-of-band, server-side reaper (EventBridge-scheduled Lambda, e.g. every 5–15 min) that:
- Lists EC2 instances tagged
spawn:managed=trueacross all spawn regions. - Reads
spawn:ttl-deadlinedirectly from the EC2 tag (the authoritative, launch-anchored value —pkg/provider/ec2.go:453, survives stop/start). - Terminates anything past deadline — including
stoppedinstances (see sibling issue for #B, the idle-stop-forever class). - Emits a notification on every reap (so a reap is visible, not silent).
Design constraints (from discussion)
- Backstop, NOT replacement. spored remains the primary enforcer (fast, local, handles idle/cost/pre-stop/graceful pre-stop hook + DNS dereg). The reaper only catches what spored missed. Do not remove or weaken in-instance enforcement.
- Communicated at launch.
spawn launchoutput should state that a server-side reaper enforces the hard deadline as a backstop — so users understand the deadline is guaranteed even if the box wedges, and that--no-timeoutdoes NOT escape it (decide: should the reaper honor--no-timeout? Leaning no — a hard org-level max age regardless). - Pre-stop on reaper-kill: the reaper terminates from outside, so the in-instance pre-stop hook won't run (instance may be wedged/stopped anyway). Acceptable for a backstop; document it. Primary path (spored) still runs pre-stop normally.
- Idempotent + rate-limited terminate calls; tolerate eventual consistency.
- Consider a hard maximum age (org policy ceiling, e.g. 7d) that applies even to
--no-timeout/ extended instances — defense against tag tampering or a deadline pushed absurdly far.
Acceptance
- A
spawn:managedinstance pastspawn:ttl-deadlineis terminated within one reaper interval even with spored stopped/killed/uninstalled. - Reaps are notified + logged.
- Launch output communicates the backstop.
- Does not interfere with healthy spored-driven termination (no double-terminate races; benign if instance already gone).
Related
- CRITICAL: spored monitor loop never runs after startup — TTL/idle/on-complete/pre-stop all silently dead #65 / CRITICAL: PrivateTmp=true hides /tmp/SPAWN_COMPLETE from spored — completion-based on-complete/pre-stop never fire #66 / fix(spored): keep lifecycle monitor alive + let it see /tmp completion (#65, #66) #67 (the lifecycle bugs that motivated this)
- Sibling: idle-stopped instances have no daemon → TTL can never fire locally (#B below)
- Sibling: forbid any TTL→stop mode (#C below)
Activity
scttfrdmn commentedon Jun 6, 2026
Sibling issues now filed: #71 (idle-stopped instances have no daemon → TTL can't fire locally; reaper must terminate stopped instances too) and #72 (guardrail: TTL must always terminate, never add a TTL→stop mode). #70 is the mechanism that backstops both.
scttfrdmn commentedon Jun 6, 2026
Folding in #71 — the idle-stop-forever case is the same problem solved by this reaper's mechanism (reading
spawn:ttl-deadlinefrom the EC2 tag is state-agnostic), so it's a requirement here, not a separate issue. Promoting to explicit acceptance criteria:MUST: the reaper's instance filter includes
stopped(andstopping), not justrunning. A naiveinstance-state-name=runningfilter would leave idle-stopped zombies billing EBS forever — that's the #71 case. Terminating past-deadline stopped instances requires no userstart.OPTIONAL (the one idea unique to #71): a shorter 'stopped max age' policy — reap an instance that's been
stoppedfor > N days even if its TTL deadline is further out (a stopped spore provides zero value). Separate policy knob; decide later.Closing #71 as folded here.
scttfrdmn commentedon Jun 8, 2026
Implemented in PR #74 (branch
feat/70-ttl-reaper), targeting v0.37.0 (tracked in #75). Built as a scheduled multi-account Lambda (lambda/ttl-reaper/): scans every spore-launching account × region forspawn:managedinstances (running AND stopped, per the folded-in #71) pastspawn:ttl-deadlineor a hardREAPER_MAX_AGEceiling, with dry-run/canary mode and notify-on-reap. Backstop, not a replacement for spored.feat(reaper): server-side TTL reaper backstop + TTL-always-terminate …
feat(windows): target-OS-aware launch + Windows connect (#55 Phase 1) (…
fix(ttl-reaper): pass sam deploy parameters via a params file (#455)
chore(taskpool): annotate exec.Command as safe for Semgrep (#70)
feat(taskpool): ScriptExecer + DirWorkspace; taskproto pooled job scr…
feat(taskpool): S3 SpecStore + Pool submitter; end-to-end Substrate t…
feat(pool): spawn pool CLI + spored pool-worker; wire taskcohort+task…
docs(changelog): spawn pool pooled execution (#70 P1)
chore(taskpool): annotate exec.Command as safe for Semgrep (#70)
Pooled task execution: worker pool for wide fan-out (#70 Phase 1) (#456)
fix(taskpool): create per-task workspaces 0700, not world-writable (#70…
2 remaining items
fix(pool): resolve AMI+IAM for workers, clean up queue on failure, su…
fix(bootstrap): retry transient spored binary/checksum/sig downloads (#…
fix(taskpool): retry OpenQueue through the create->GetQueueUrl consis…
Release v0.96.2
fix(pool): scoped worker IAM profile with SQS + S3 access (#70) (#467)
Release v0.96.3
scttfrdmn commentedon Jul 31, 2026
✅ Pool validated end-to-end on real AWS (spawn v0.96.3)
The 4th real-AWS smoke passed — the pooled-execution engine works end-to-end for the first time:
Workers provisioned as a cohort → installed spored → resolved the run queue → pulled tasks → ran them → wrote durable completion records → the pool drained. Then auto-torn-down and leak-checked clean (0 workers, 0 queues, no orphans, independently re-verified). ~2× t3.micro for a few minutes.
What it took: 4 releases, one bug per layer
Each paid smoke surfaced the next layer's bug — all fixed and released:
MissingParameter(taskcohort Actuator calls RunInstances directly, bypassing the auto-fillspawn task rungets from launcher.Provision).OpenQueueraced queue creation (SQS eventual consistency) → NonExistentQueue at boot.Why Substrate didn't catch these (+ filed enhancements)
Substrate's control-plane tests were green because 3 of the 4 gaps are exactly what it doesn't model: IAM-as-enforced (it has an evaluator but nil-Principal always passes), RunInstances required-param validation, and instance-internal bootstrap. Filed scttfrdmn/substrate#411 (principal-aware test mode), #412 (validate empty ImageId), #413 (seedable GetQueueUrl consistency). The spored-internal bugs (#463) are genuinely out of any emulator's scope — a real-AWS smoke gate is the complement.
Remaining
spored pool-workeronce at boot; it should be restart-on-exit so a transient failure doesn't strand a billing-but-idle worker (didn't bite this green run, but worth hardening).nf-spawn/docs/pool-validation-runbook.md— the engine it exercises is now proven.docs(gen): regenerate pool reference for --s3-read/--s3-write flags (#70
feat(pool): resilient restart-on-error workers (#465) + task-bucket I…
Release v0.97.0
scttfrdmn commentedon Jul 31, 2026
✅ Scaled validation green (spawn v0.97.0) — the #70 win, measured
Ran a larger synthetic pool run to measure concurrency + dispatch at fan-out (12 workers / 24 trivial tasks, dev account, auto-torn-down + leak-checked clean). This exercises the scaling behavior #70 is about; the N=108-with-the-real-bcftools-pipeline remains the owner's to run (needs the real pipeline + genomes) via
nf-spawn/docs/pool-validation-runbook.md.Before → after (the core #70 fix, now demonstrated)
Dispatch is now O(SendMessage), decoupled from instance launch, and concurrency is bounded by the pool size you ask for — not by how fast RunInstances can fire. The follow-ups from the earlier round both held under load: workers ran the restart-supervised pull loop (#465) and drained cleanly to $0.
Status
The pooled-execution engine is validated end-to-end and at scale on real AWS, shipped in v0.97.0 (pool
--s3-read/--s3-write+ resilient workers included). The remaining item — the full nf-core/bcftools N=108 acceptance run on real data — is the owner's to run via the runbook; the engine it exercises is proven.docs: mark pooled-execution design as shipped; consolidate v0.97.0 ch…
feat(cloudformation): authorize a stack's resource calls and model it…
fix(sweep-orchestrator): make detached sweep rows reapable (#725)
fix(sweep-orchestrator): make detached sweep rows reapable (#725) (#726)