Skip to content

fix(taskproto): create output-only mount dirs and fix staged-input ownership (#564, #565) - #568

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/564-565-container-fs-ownership
Sep 3, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/564-565-container-fs-ownership

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Summary

Fixes two follow-on gaps from #555 (4a8386f, container runs as --user "$(id -u):$(id -g)"), both in the filesystem-ownership family between host, container, and Docker's own auto-created-directory behavior.

#564 — directory outputs cannot work on the container path

The stage-in mkdir -p loop only iterated spec.Inputs, so an output whose Source directory wasn't shared with any input (e.g. outputs: [{source: "/tmp/out/", ...}] with no input under /tmp/out) was never created on the host. docker run -v /tmp/out:/tmp/out then auto-created it — as root, mode 0755 — so the non-root container got EACCES on its first write, before producing any output.

Fix: the mkdir loop now iterates containerMountDirs(spec) directly — the exact same set docker run -v mounts — instead of recomputing a separate, narrower set. The two lists can no longer drift apart.

examples/task-spec.json was checked and does not need a change: its output (/work/result.bam) shares a parent (/work) with an input (/work/sample.fastq.gz), so it was never on the failing side of this bug (verified with a scratch test asserting containerMountDirs against the real example file).

#565 — staged inputs land in sticky /tmp, container can't rm them

Stage-in (aws s3 cp) runs on the host as the instance user; host /tmp is sticky (mode 1777). Sticky-bit unlink requires owning the file, not just sharing the directory's uid. In the current wrapper, stage-in and docker run --user "$(id -u):$(id -g)" happen to share one uninterrupted su - <user> shell session, so today the uids match by construction — but that's fragile, not structural.

Investigated both suggested fixes (chown vs. a non-sticky per-task staging dir) rather than assuming either would work as-is:

  • Verified with a real Docker-based sticky-bit repro (named volumes / real containers, not a macOS bind mount — the issue's own caveat) that a genuine uid mismatch does reproduce EPERM on unlink, and that a non-root chown cannot repair a real mismatch (only root can reassign ownership away from the current owner) — a plain chown would have been a silently-impotent no-op exactly when it mattered.
  • Chose (a) chown, via sudo: smaller and more surgical than introducing a new staging-directory convention, and the target uid:gid is already known at wrapper-generation time (same value --user uses). sudo is available — the instance user already has passwordless sudo, the same precondition writeContainerRun's docker/dnf calls rely on.
  • The chown is emitted unconditionally after every aws s3 cp, using the identical "$(id -u):$(id -g)" expression --user uses, with -R for prefix (recursive) inputs.

Test plan

🤖 Generated with Claude Code

@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…nership (#564, #565)

output whose Source directory wasn't shared with any input was left for
`docker run -v` to auto-create — which Docker does as root, mode 0755,
leaving the non-root container (--user "$(id -u):$(id -g)" per #555) unable
to write into it. The mkdir loop now iterates containerMountDirs' own
output directly, so the mount set and the pre-create set can never drift
apart again.

a real mismatch rather than no-op) to the same "$(id -u):$(id -g)" that
docker run --user uses, right after aws s3 cp lands it. Host /tmp is sticky
(mode 1777): unlinking a file there requires owning that specific file, not
just sharing the directory's uid, so a task that untars a staged archive
and deletes it could still hit EPERM if ownership ever diverged from the
container's --user uid. Verified the sticky-bit mechanism directly with a
Docker-based repro (real Linux semantics, not a macOS bind mount) rather
than assuming the issue's suggested fix would work as-is.

examples/task-spec.json checked and left unchanged: its output directory
is already shared with an input, so it isn't on the failing side of #564.
@scttfrdmn
scttfrdmn force-pushed the fix/564-565-container-fs-ownership branch from 7b03bb7 to 99f8f42 Compare September 3, 2026 20:00
@scttfrdmn
scttfrdmn merged commit c327274 into main Sep 3, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the fix/564-565-container-fs-ownership branch September 3, 2026 20:10
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