Repository navigation
fix(taskproto): create output-only mount dirs and fix staged-input ownership (#564, #565) - #568
Merged
Merged
Conversation
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
force-pushed
the
fix/564-565-container-fs-ownership
branch
from
September 3, 2026 20:00
7b03bb7 to
99f8f42
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 -ploop only iteratedspec.Inputs, so an output whoseSourcedirectory 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/outthen auto-created it — as root, mode 0755 — so the non-root container gotEACCESon its first write, before producing any output.Fix: the mkdir loop now iterates
containerMountDirs(spec)directly — the exact same setdocker run -vmounts — instead of recomputing a separate, narrower set. The two lists can no longer drift apart.examples/task-spec.jsonwas 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 assertingcontainerMountDirsagainst 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/tmpis sticky (mode 1777). Sticky-bit unlink requires owning the file, not just sharing the directory's uid. In the current wrapper, stage-in anddocker run --user "$(id -u):$(id -g)"happen to share one uninterruptedsu - <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:
EPERMon unlink, and that a non-rootchowncannot repair a real mismatch (only root can reassign ownership away from the current owner) — a plainchownwould have been a silently-impotent no-op exactly when it mattered.chown, viasudo: 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--useruses).sudois available — the instance user already has passwordless sudo, the same preconditionwriteContainerRun's docker/dnf calls rely on.aws s3 cp, using the identical"$(id -u):$(id -g)"expression--useruses, with-Rfor prefix (recursive) inputs.Test plan
TestGenerateWrapper_MkdirCoversOutputOnlyDir/TestGenerateWrapper_MkdirLoopMatchesContainerMountDirs(task: directory outputs (Manifest source ending in /) cannot work on the container path #564, text-based) — fail without the fix, pass with it (verified viagit stash)TestGenerateWrapper_OutputOnlyDirExistsBeforeDockerRun(task: directory outputs (Manifest source ending in /) cannot work on the container path #564, exec-based) — runs the real generated stage-in preamble under bash, asserts the dir exists with correct ownership beforedocker runwould need itTestGenerateWrapper_ChownsStagedInputToInvokingUID/TestGenerateWrapper_ChownRecursiveForPrefixInput(Staged inputs land in sticky /tmp owned by the instance user, so a container running as another uid cannot rm them #565, text-based) — fail without the fix, pass with itTestGenerateWrapper_StagedFileOwnedByInvokingUID_RealFilesystem(Staged inputs land in sticky /tmp owned by the instance user, so a container running as another uid cannot rm them #565, exec-based) — real sticky-bit (1777) dir on the test filesystem, proves the chown leaves correct ownershipTestGenerateWrapper_ChownFixesCrossUIDStickyUnlink_Docker(Staged inputs land in sticky /tmp owned by the instance user, so a container running as another uid cannot rm them #565, strongest proof) — extracts the actual chown lineGenerateWrapperemits and runs it for real inside Docker (genuine Linux sticky-bit semantics) against a deliberately mismatched uid; confirms both that the bug reproduces without the fix and that the extracted real line repairs itmake checkclean (fmt/vet/short tests) — pre-existing staticcheck warnings are unrelated to this diffmake check-docsclean — no flag/help text touched, no driftlambda/*/go.modmodules build cleanly (nogo mod tidyneeded)lambda/autoscale-orchestrator/autoscale-orchestratorbinary artifact checked for and excluded from the commit🤖 Generated with Claude Code