Skip to content

fix: stage-out skips inputs stage-in symlinked to a mount (#99) - #110

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/99-stage-out-skips-symlinked-refs
Nov 8, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/99-stage-out-skips-symlinked-refs

Conversation

@scttfrdmn

Copy link
Copy Markdown
Collaborator

Fixes #99

Refs spore-host/spore-host#644 (pre-1.0 hardening).

Root cause

Stage-in (#55/#67, and #51 for local-path inputs) makes a declared path input zero-copy by ln -sfn-ing its stage name inside ${LOCAL_DIR} to the mount. Stage-out is aws s3 sync "${LOCAL_DIR}/" "${WORKDIR_S3}", and aws s3 sync follows symlinks by default. So the sync walked into /fsx/kraken2 (etc.) and uploaded the whole reference DB into every task's work dir.

Fix

Option 2 from the issue: the output sync gets --exclude '<stage>' --exclude '<stage>/*' for each stage name that stage-in symlinked. symlinkedStageNames() uses the same two conditions as buildInputStaging's two ln -sfn branches: a mount-basename match, or a local absolute-path source. The mount index is factored into one helper shared by both, so the two can't drift.

  • I did not use --no-follow-symlinks. It would also drop symlinks the task itself creates, and nf-core modules do emit symlinked outputs, so those would silently go missing.
  • Stage names are bracket-escaped (*, ?, [) because AWS CLI filters are fnmatch globs.
  • When nothing was symlinked, the sync line is byte-identical to before.

Verification

  • 4 new Spock tests in SpawnTaskHandlerTest. The two that assert the exclusion fail without the fix (checked by reverting only the sync line: 109 tests completed, 2 failed).
  • Filter semantics were checked against the real AWS CLI 2.39.5 code (FileGenerator(follow_symlinks=True) + create_filter) on a local dir with kraken2 -> fsx/kraken2. Without the excludes it yields kraken2/hash.k2d and report.txt. With them it yields only report.txt. A symlinked file named db[1].fa is excluded by the escaped glob too. No AWS was reached.

Not in scope (observation)

Inputs that are copied in (e.g. the 2.84 GB fastqs in the issue's listing) are still re-uploaded by the same sync, because they are regular files in ${LOCAL_DIR}. That is a separate duplication and is not addressed here.

Before merge

A live run would confirm the S3 listing: one task with an ext.fsx/ext.volumes DB, then check that its work dir holds no kraken2/ objects.

aws s3 sync follows symlinks, so the #55/#67 zero-copy reference DB was
uploaded into every task's S3 work dir. Exclude each symlinked stage name
(and everything under it) from the output sync; other symlinks are still
followed.
@scttfrdmn

Copy link
Copy Markdown
Collaborator Author

Live verification: PASS for #99's scope (spore-host-dev, 2026-11-08)

Setup.

This PR. The work dir holds no object from the mounted DB:

$ aws s3 ls --recursive s3://nf-live-.../work110/
work110/f1/61c2ca3e7f257bf957c1b924dc25f4/.command.err    0
work110/f1/61c2ca3e7f257bf957c1b924dc25f4/.command.out    0
work110/f1/61c2ca3e7f257bf957c1b924dc25f4/.command.sh   151
work110/f1/61c2ca3e7f257bf957c1b924dc25f4/.exitcode       3
work110/f1/61c2ca3e7f257bf957c1b924dc25f4/report.txt    362

command.log has nf-spawn: input 'kraken2' → ext.volumes mount /opt/databases/kraken2 (basename match; symlinked, copy skipped). report.txt shows the task read the DB through the link (stage-name target: /opt/databases/kraken2, hash.k2d 3000000, ref).

Control: released v0.11.0, same config. The bug reproduces, and the whole DB is republished:

work110ctl/d9/25d15f.../kraken2/kraken2/hash.k2d   3000000
work110ctl/d9/25d15f.../kraken2/kraken2/opts.k2d         4
work110ctl/d9/25d15f.../kraken2/kraken2/taxo.k2d    200000

A separate, pre-existing bug the live run found (filed as #117). Both runs ended with exit 75 (nf-spawn: output sync ... failed).

Cost: 2 × t4g.small for about 1 min each, plus a t4g.nano for about 2 min to build the snapshot. Everything was torn down.

Leak check (us-east-1 and us-west-2, after teardown).

  • No instances pending, running, stopping, stopped or shutting-down. No open or active Spot requests.
  • No unattached volumes; the test snapshot snap-0120c9d0f4e4384fd and its source volume are deleted.
  • No unassociated EIPs, no new security groups or key pairs, and no spawn-pool* SQS queues.
  • The scratch bucket nf-live-435415984226-20261108 is removed, as are this run's tasks/* and staging/pool-specs/* records in spawn-results-435415984226-us-east-1.
  • The per-task role spawn-instance-1342ea0f remains (spawn-managed, removed by spawn cleanup --instance-roles or the reaper after the 24 h guard). The pool roles were already gone.

@scttfrdmn
scttfrdmn merged commit e67269f into main Nov 8, 2026
4 checks passed
@scttfrdmn
scttfrdmn deleted the fix/99-stage-out-skips-symlinked-refs branch November 8, 2026 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stage-out follows the #55 stage-in symlink → republishes the whole shared reference DB per task (6.51 TB of a 12 TB work dir)

1 participant