Repository navigation
Description
Context
Split out from #92 (docker socket permission fix). The reporter observed, while diagnosing the exit-126 docker-permission bug:
instances did not promptly self-terminate. A failed task's instance (exit 126) was still
runningafter the pipeline aborted (I terminated it manually; TTL would eventually reap it), and even a completed task's instance lingered ~1-2 min post-completion.
What's confirmed NOT a bug
The completed-task ~1-2 min lingering matches spored's known lifecycle ticker: Agent.Monitor in spawn's pkg/agent/agent.go polls checkAndAct (which drives on_complete) on a ticker that defaults to 1 * time.Minute (interval := a.monitorInterval; if interval <= 0 { interval = 1 * time.Minute }, line ~316-319). A completion signal that lands just after a tick fires waits up to ~1 tick period before the next tick notices it and acts — bounded, expected behavior, not a bug.
What's NOT yet explained — needs live investigation
The failed-task instance allegedly stayed running (not just laggy — requiring manual termination) is harder to reconcile with the code as read statically:
- nf-spawn's
SpawnTaskHandler.buildTaskSpec(src/main/groovy/io/nextflow/spawn/SpawnTaskHandler.groovy) does NOT setspec.container— nf-spawn does its owndocker runinside its staging script, and that whole staging script is handed to spawn asspec.command = ['/bin/bash', '-lc', stagingScript]. spawn task runexecutes this viataskproto.GenerateWrapper(pkg/taskproto/wrapper.goin spore-host/spawn), which runs the ENTIRE nf-spawn staging script as a subshell (( %s )), capturesrc=$?from it, and then unconditionally writescompletion.jsonand/tmp/SPAWN_COMPLETEbased on thatrc— regardless of whether the failure was a docker permission error (rc=126) or anything else. This is the defaultsignalComplete=truepath (one-instance-per-task, not the pooled-worker path).- Given that,
on_complete(terminate) should fire on the very next 1-minute tick even for a failed exit-126 task — same as a successful one.
So there's no obvious code-level reason a failed task's instance would linger any longer than a completed one. Possible explanations, none confirmed:
- The reporter checked before the next 1-minute tick fired (i.e., not actually a bug — just impatience/timing, same bound as the completed case).
- Some interaction between Nextflow's pipeline-abort behavior (when other tasks in the DAG fail and Nextflow tears down the run) and spored's completion signal / instance state at that moment.
- A genuine gap specific to the failure path — e.g., IMDS/tag propagation, or an interaction with
nf-spawn'skillTask()(which callsspawn terminatewhen Nextflow explicitly kills a task) racing or conflicting with spored's ownon_completeself-termination. - Possibly noise from the Containerized processes fail exit 126: nf-spawn's docker run can't reach the Docker socket (task user not in docker group) #92 bug itself (every task was failing in a confusing way) that may not reproduce now that Containerized processes fail exit 126: nf-spawn's docker run can't reach the Docker socket (task user not in docker group) #92's docker-socket fix has landed.
Ask
Needs a live, real-AWS re-run (now that #92 is fixed) with a deliberately-failing containerized task (e.g. container pointing at an image with a script that exits non-zero) to observe:
- Does the failed instance's
/tmp/SPAWN_COMPLETE/completion.jsonget written promptly? - Does
on_complete terminatefire within the expected ~1-2 min bound, same as the completed case? - If not, capture spored's own logs on the instance (
journalctl -u sporedor wherever it logs) to see what it observed and when.
This is intentionally NOT bundled into #92's fix — it needs live observation to confirm or refute, not a code-level fix based on speculation.
Activity
scttfrdmn commentedon Sep 5, 2026
Live re-run — confirmed NOT a bug (hypothesis 4, "#92-era noise")
Ran a real DAG on AWS today with nf-spawn built from current
main(7412d54, plugin manifestPlugin-Version: 0.10.0, includes #92's sudo-docker fix and #90/#91) againstspawnv0.104.0 (git2ff3412). Account/region:spore-host-dev(435415984226),us-east-1.Pipeline (
/tmp/issue93-repro/main.nf): twocontainer 'ubuntu:22.04'processes,t3.micro,ttl=10m,workDir = s3://spawn-results-435415984226-us-east-1/nf-runs/issue93-repro-20260905-213804—OK_TASK— exits 0FAIL_TASK— deliberatelyexit 3What happened (timestamps UTC)
nf-5c21879fafe7OK,nf-ba74367de3efFAIL)docker runexits rc=3 (command.log:command exit rc=3)completion.json(state: failed, exit_code: 3, retry_class: app_error),.exitcode=3checkIfCompleted()observes it, task handler logsTask 'FAIL_TASK' failed (exit 3)killTask()on the other, still-runningOK_TASK— explicitspawn terminateOK_TASKexplicit terminate confirmed (Terminated spawn instance 'nf-5c21879fafe7') — this one died viakillTask(), not on_completei-0e06ed1d72b840fd0) stillrunningshutting-downterminatedSo FAIL_TASK's own instance self-terminated via spored's
on_complete: terminate~2m08s–2m28s after its completion record landed — the same ~1-2 min ticker bound documented for the successful case (spawn'sAgent.Monitor/checkAndAct1-minute ticker), not materially different. No lingering, no manual intervention needed, no gap in the failure path.Which hypothesis this confirms
Hypothesis 4 — noise from #92 itself. #92 (fixed, PR #94, merged before this run) meant every containerized task failed exit 126 with
docker: permission denied, before nf-spawn's own docker-run line ever produced a real, task-level exit code. Under that bug it's plausible the completion record / S3 artifacts the reporter was checking for were confused with the docker-permission failure itself, or the reporter observed the box before this same ~1-2 min bound elapsed and (reasonably) assumed something was stuck, since it was already suspicious that every task was failing in a confusing, opaque way.With #92 fixed, the completion record for a failed task is written just as promptly as for a successful one (both via
taskproto.GenerateWrapper's unconditional stage-out + completion-record path, exactly as the static read in this issue predicted), andon_complete: terminatefires on the identical ~1-2 min ticker bound in both cases. I did not find any gap specific to the failure path, and no interaction betweenkillTask()and on_complete caused a leak either —killTask()only fired against the other, non-failed task in the DAG (an explicitspawn terminate, logged and confirmed), which is expected Nextflow DAG-abort behavior (hypothesis 2 territory) and worked correctly, not a race.One adjacent, real bug worth noting for context (not a nf-spawn issue, and already fixed upstream): spawn had spore-host/spawn#566 — a task whose command failed produced no completion record at all (the wrapper inherited
set -efrompkg/launcher/bootstrap.go's preamble and aborted beforerc=$?/stage-out/the completion write), so a failed task really did ride to TTL instead of self-terminating. That's fixed in spawn v0.103.1 (set +emade explicit in the wrapper, spawn#567) and is what this run was implicitly re-verifying at the spawn layer too — the repro above shows the fixed behavior (prompt completion record + prompt on_complete on the failure path).Cost-safety confirmation
i-0e06ed1d72b840fd0(FAIL_TASK,nf-ba74367de3ef),i-08d8c9fdee85b8a1f(OK_TASK,nf-5c21879fafe7).i-08d8c9fdee85b8a1f: terminated via nf-spawn'skillTask()(spawn terminate) at 21:40:21, confirmedterminated.i-0e06ed1d72b840fd0: self-terminated via spored'son_complete: terminateat 21:42:22, confirmedterminated.aws ec2 describe-instancesinus-east-1(and spot-checkedus-east-2/us-west-2): zero non-terminated instances remain from this investigation.Conclusion
Closing as confirmed-not-a-bug: hypothesis 4 (noise from the now-fixed #92) is the best fit for the original observation, with hypothesis 1 (timing/impatience) plausibly compounding it — a "stuck" box during the #92 outage, re-checked today with #92 fixed, now self-terminates on the same bound as a successful task. No nf-spawn code change needed.