Skip to content

fix: mount attached storage before the user-data/command script (#166) - #167

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/166-mount-volumes-before-user-script
Jun 14, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/166-mount-volumes-before-user-script

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Closes #166. A serious ordering bug that undermines the whole ext.volumes zero-copy DB workflow (nf-spawn 0.5.0) — on both the head and the tasks.

The bug

The storage-mount script (EFS / FSx / --attach-volume) was appended to the end of user-data:

userDataScript += "\n" + storageScript   // after the user's script

So the user's --user-data/--command workload ran first, to completion, and the volumes mounted after it. The filer's head-node boot log shows a pipeline validating /opt/databases/metaphlan, failing because it's unmounted, then mkdir+mount running. The volumes end up correctly mounted — just minutes too late to be useful.

Fix

Build the storage script first and inject it before the user's script, inside the bootstrap:

  • New BootstrapConfig.StorageScript — emitted right before CustomUserData in BuildLinuxBootstrap (under set +e, so a mount hiccup can't skip the user script).
  • buildUserData takes the storage script and threads it through; the single-instance path builds it before buildUserData instead of appending after.
  • Job-array path: removed its separate storage re-append — the base user-data already carries the mount (now correctly placed), so re-appending would both double-mount and re-introduce the after-the-script ordering. MPI user-data remains the only per-instance addition.

Why this also fixes the task side

nf-spawn ships its task staging script as --user-data-file, i.e. it becomes CustomUserData. So the task's .command.sh now runs after the volume mount too — which is exactly what ext.volumes (symlink stage-name → mount) needs.

Tests

  • TestBuildLinuxBootstrap_StorageMountsBeforeUserScript — asserts the storage marker precedes the user-script marker (the regression guard).
  • TestBuildLinuxBootstrap_NoStorageScriptWhenEmpty — no storage section when unset.
  • All five buildUserData call sites updated; make check green.

Note for the demo

This is why the smoke test would have failed even with everything else correct — the head's pipeline validated db_path before spawn mounted the volume. With this fix the mount is live before nextflow run starts. Needs a fresh launch on the new spawn build (the ordering is baked into user-data at launch).

The EFS/FSx/--attach-volume mount script was appended to the END of user-data,
so it ran AFTER the user's --user-data/--command workload had already completed.
A program launched by user-data that needed the volume (e.g. an nf-core pipeline
validating its db_path mount exists) saw an unmounted path and failed; the
volumes only mounted once the workload had finished — useless.

Fix: build the storage-mount script first and inject it BEFORE CustomUserData in
the Linux bootstrap (new BootstrapConfig.StorageScript), instead of appending it
after. buildUserData now takes the storage script and threads it through
BuildLinuxBootstrap. The job-array path no longer re-appends storage (the base
user-data already has it, correctly placed) — that also fixes a latent
double-mount.

This covers both the head node and the per-task path that nf-spawn's ext.volumes
zero-copy DB workflow relies on (nf-spawn's task staging script is the
CustomUserData, so it now also runs after the mount).
@codecov

codecov Bot commented Jun 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 28.57143% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/launch.go 0.00% 9 Missing ⚠️
cmd/resume.go 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit ae2ad1e into main Jun 14, 2026
2 of 3 checks passed
@scttfrdmn
scttfrdmn deleted the fix/166-mount-volumes-before-user-script branch June 14, 2026 17:01
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.

--attach-volume mounts run AFTER the --user-data/--command script, so a program in user-data can't see the volumes

1 participant