Skip to content

feat: dispatch each task via spawn task run (spawn#386 adapter migration) - #73

Merged
scttfrdmn merged 1 commit into
mainfrom
feat/386-task-run-migration
Jul 20, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
feat/386-task-run-migration

Conversation

@scttfrdmn

Copy link
Copy Markdown
Collaborator

Summary

Ports nf-spawn — the last and hardest adapter — to the spawn task-execution protocol (spawn#386). submit() stops calling spawn launch and instead builds a TaskSpec and shells out to spawn task run (detached). spawn now owns launch, sizing, the durable completion record, self-termination, and a scoped least-privilege instance profile.

Design decision: keep nf-spawn's staging script (option b)

Unlike the other four adapters, nf-spawn's staging has behaviors spawn's wrapper doesn't replicate: input localization by source URI (#37), directory detection, the zero-copy symlink short-circuits (#55/#49) that let a path-input reference DB resolve to an ext.volumes/FSx mount, the s3:/// repair (#41), and its own docker run with resolved runOptions/bind-mounts. Faithfully porting those into spawn's manifest model would regress nf-core pipelines. So nf-spawn keeps its staging script, which becomes the TaskSpec command (bash -lc) — identical bash on the instance. There are no inputs/outputs manifests; instead the work bucket is declared in resources.s3_read_write so the scoped profile grants exactly the S3 access the script's aws s3 sync/cp need.

Mapping

  • ext.instanceType → resources.instance_type — an exact pin (spawn#413). Critical: nf-spawn's type is exact (default t3.medium) with no cpu/mem, so a family-only hint would size to the cheapest in-family (t3.nano) — a severe silent downsizing.
  • ext.ami/ext.az/ext.volumes/ext.fsx/ext.efs → the placement block (spawn ≥ 0.84.0).
  • ext.spot → resources.purchase=spot + fallback=on_demand.
  • Completion: checkIfCompleted() still reads the durable .exitcode from the S3 work dir (the authoritative signal carrying the real task exit code, checkIfRunning() treats EC2 propagation-window NotFound as task failure — race condition on first poll #34); checkIfRunning() polls spawn task status --check-complete; killTask() → spawn terminate <task-id>.

The completion-signal race (subtle, fixed)

spawn's wrapper writes /tmp/SPAWN_COMPLETE after stage-out + completion.json. nf-spawn's staging script also touched it (its spored complete fallback) mid-command — which would let spored terminate the box before the completion record uploads. Fixed with a signalCompletion flag: under task-run the script instead exits with the task's real code (which the wrapper records) and never touches SPAWN_COMPLETE. The legacy path is unchanged.

Testing

  • Spock suite green (new tests: buildTaskSpec exact-pin + placement mapping, buildTaskRunCommand detached, s3BucketUri, the signalCompletion behavior). compileGroovy + test + assemble all green (JDK17, Nextflow 26.04.3).
  • Requires spawn ≥ 0.85.0 (the instance_type pin lands in the next spawn release).
  • Gated real-AWS smoke pending (a Nextflow pipeline, per cost-safety) — not merging/releasing until it passes.

Refs spore-host/spawn#386

…ion)

Ports nf-spawn to the shared workflow-adapter protocol. submit() builds a spawn
TaskSpec and runs `spawn task run` (detached) instead of calling `spawn launch`;
checkIfRunning() polls `spawn task status --check-complete`; killTask()
terminates by task id. spawn owns launch, sizing, the durable completion record,
self-termination, and a scoped instance profile.

Design (option b): nf-spawn KEEPS its own staging script — input localization
(#37), zero-copy symlink short-circuits (#55/#49), and its own `docker run` are
behaviors spawn's wrapper doesn't replicate, so faithfully porting them into
spawn's manifest model would regress nf-core pipelines. The staging script
becomes the TaskSpec `command` (bash -lc), running identical bash on the
instance. No inputs/outputs manifests; the work bucket is declared in
resources.s3_read_write so the scoped profile grants the S3 access the script's
aws s3 sync/cp need.

- ext.instanceType → resources.instance_type (EXACT pin, spawn#413 — a family
  hint would size t3.medium→t3.nano). ext.ami/az/volumes/fsx/efs → placement.
- Staging script gains signalCompletion flag: under task-run it exits with the
  task's real code and does NOT touch /tmp/SPAWN_COMPLETE (which would race the
  wrapper's own completion signal, terminating the box before completion.json
  uploads). Legacy path unchanged.
- Requires spawn >= 0.85.0 (instance_type pin). Compile + Spock + assemble green.
  Real-AWS smoke (a Nextflow pipeline) pending, gated.

Refs spore-host/spawn#386
@scttfrdmn
scttfrdmn merged commit 209f0c5 into main Jul 20, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant