Repository navigation
fix(taskproto): create bind-mount dirs with privilege (#564), and document the real staging contract - #649
Conversation
…omes from `task run --help` said only "the manifest dirs are bind-mounted", which reads as though any path works for any image. The reporter on #620 identified it as exactly what led them to the wrong conclusion twice. Verifying their two points against the code turned up something better than a docs gap: both constraints they wanted documented have already been lifted, and documenting them would have encoded obsolete advice. - "The container runs as the image's user (bioconda = mambauser uid 57439)" is no longer true. #555 (ac5655a, 2026-09-02) added `--user "$(id -u):$(id -g)"`, evaluated in the same shell as stage-in, so the container runs as the instance user BY CONSTRUCTION rather than by luck. - "Output parents are never mkdir-ed, so dockerd creates them as root" and "the container gets EPERM unlinking a staged input" were both fixed by c327274 (2026-09-03) — whose title names both issues: "create output-only mount dirs and fix staged-input ownership (#564, #565)". Confirmed by generating a wrapper with a directory output under a distinct parent: every mount dir gets `mkdir -p` as the instance user, every staged input a `sudo chown "$(id -u):$(id -g)"`, and a trailing-slash manifest stages with `aws s3 cp --recursive` in both directions. So the help text now says the opposite of the workaround: any absolute path works, the image's USER is irrelevant, and staged paths do NOT need to be kept flat in /tmp. The genuinely non-obvious fact that remains true is documented plainly: resources.disk_gib sizes the ROOT EBS volume, so it governs an ordinary path like /work — while /tmp on AL2023 is a tmpfs capped near half of instance memory, so a 40 GiB index staged into /tmp fails on a 32 GiB box regardless of disk_gib. The reporter's measurement that sizing for a staging footprint in MEMORY tends to pick the instance family rather than its size (m8g.2xlarge at 44% less than the c8g.4xlarge vCPU count implied) is the reason that distinction is worth stating rather than leaving to inference. #564 and #565 are left OPEN deliberately. Their fixes are in the code, but these were reported from real instances and #606 is the standing lesson that real-hardware validation catches what code-tracing misses — so they want a real run to confirm before closing, not my reading of the generated script. Refs #620
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…aths work Real-AWS validation of #564/#565 found that my earlier reading of the code was wrong, and that only one of the two was actually fixed. #565 IS fixed. On a real t4g.medium: uid=1000 gid=1000 groups=1000 drwxrwxrwt 11 0 0 320 /tmp <- sticky 1777 -rw-r--r-- 1 1000 1000 42 /tmp/staged.bin rm exit=0 / PASS-565 --user does override the image's declared USER (alpine declares root; the container ran as 1000) and the staged input is owned by that uid, so the sticky-bit unlink succeeds. #564 was NOT fixed, and the mkdir I pointed at as proof is the bug: mkdir: cannot create directory ‘/out’: Permission denied spawn: [...] stage-in done rc=0 <- failure swallowed drwxr-xr-x 2 0 0 /out/results <- docker -v made it, as root sh: can't create /out/results/a.txt: Permission denied The mkdir IS emitted, but it runs as the unprivileged instance user, so it cannot create a directory whose parent it does not own — every top-level path: /out, /data, /work. So the auto-creation-as-root that the loop exists to prevent happened anyway, 90 seconds later, as a container permission error with nothing pointing at the host-side failure. spawn's own documented /data + /work example could not work, and /tmp was in practice the only usable staging location, which is what forced callers to keep staged paths flat. A code read cannot catch this: the mkdir is present either way, and only a real instance shows it returning non-zero. #606 is the standing lesson and I repeated it — asserting on the issue that #564's premise was false before testing it. Fix: try the unprivileged mkdir first and escalate to `sudo mkdir -p` plus a chown to the invoking uid only when that fails, so no privilege is used where none is needed. A directory that still cannot be created sets STAGE_RC, failing the task AT stage-in as staging_error rather than running the command against an unwritable mount. The chown is gated on the directory not already existing, and that guard is load-bearing rather than an optimization: a destination of /tmp/staged.bin yields a mount dir of /tmp, and chowning THAT would strip the sticky ownership every other user on the box depends on — far worse than the bug being fixed. TestMountDirNeverChownsAnExistingDirectory executes the generated block against an existing directory and asserts sudo is never invoked. Re-validated on real AWS with the same spec: state=completed, exit 0, /out/results now drwxr-xr-x 2 1000 1000 (was root), and the directory output staged recursively to S3 including its subdirectory (a.txt, sub/c.txt). Both instances terminated and leak-checked (zero instances, no orphaned volumes); ~$0.004 total. The --help text in this branch is now true rather than aspirational: it ships with the fix that makes "any absolute path works" correct. The exec-based wrapper tests gained a `sudo` stand-in, deliberately narrow — it passes everything through EXCEPT mkdir/chown, because a blanket pass-through also swallowed `sudo docker run` and masked a user command's real exit code. Also updated the test's placement-mount assertion: FSxMountPoint only takes effect alongside an FSxLustreID, so my first version asserted nothing. Fixes #564 Refs #620, #565
Scope changed: this now carries the #564 fix, because the docs I wrote were wrongPushed 8ba018b. Do not read the original PR description as current — I retitled this and the docs text has changed. I wrote "any absolute path works ... you do not need to keep staged paths flat in /tmp" based on a code read. A real-AWS run disproved it. The two issues came apart: #565 — fixed, confirmed on a real t4g.medium#564 — NOT fixed, and the mkdir I cited as proof is the bugThe A code read cannot catch this — the mkdir is present either way; only a real instance shows it returning non-zero. #606 is the standing lesson in this repo and I repeated it. The fixUnprivileged The chown is gated on the directory not already existing, and that guard is load-bearing. A destination of Re-validated on real AWS, same spec
Both instances terminated and independently leak-checked (zero running instances, no orphaned volumes). ~$0.004 total. So the Two smaller notes: the exec-based wrapper tests gained a My own changelog gate also caught a duplicate |
Refs #620. Deliberately not
Fixes— see the last section.The gap
task run --helpsaid only "the manifest dirs are bind-mounted", which reads as though any path works for any image. The reporter on #620 named it as exactly what led them to the wrong conclusion twice.What verifying their points turned up
I checked both facts against the code before writing them down, and both constraints have already been lifted. Documenting them as asked would have encoded obsolete advice into the help text:
mambauseruid 57439)"ac5655a, 2026-09-02) added--user "$(id -u):$(id -g)", evaluated in the same shell as stage-in, so the container runs as the instance user by construction — not, as #565 argued, "by luck of the AMI".mkdir-ed, so dockerd creates them as root" (#564)c327274(2026-09-03).EPERMunlinking a staged input" (#565)Confirmed by generating a wrapper with a directory output under a distinct parent and reading the emitted script:
Every mount dir is pre-created as the instance user; every staged input is chown'd to that uid; the container runs as that uid; a trailing-slash manifest stages recursively in both directions.
So the help text now says the opposite of the workaround: any absolute path works, the image's
USERis irrelevant, and staged paths do not need to be kept flat in/tmp.What is still true, and is the actually useful part
resources.disk_gibsizes the root EBS volume (pkg/taskproto/taskspec.go:48), so it governs an ordinary path like/work./tmpon AL2023 is a tmpfs, capped near half of instance memory — so a 40 GiB index staged into/tmpfails on a 32 GiB box no matter how largedisk_gibis.The reporter's measurement is what makes this worth stating rather than leaving to inference: sizing for a staging footprint in memory tends to pick the instance family rather than just its size (
m8g.2xlargeat 44% less than thec8g.4xlargethe vCPU count alone implied). The two choices are not interchangeable on cost.Why #564 and #565 stay open
Their fixes are in the code, but I am not closing them on a code read. Both were reported from real instances, and #606 is the standing lesson in this repo that real-hardware validation catches what code-tracing and dry-runs miss. They want a real run to confirm.
Worth noting why they looked open: PR #568 merged the fixes on 2026-09-03 with no closing keyword in its body, so neither issue auto-closed — the same bookkeeping gap that left #615 open after #634. The fixes shipped; the issues just never got updated.
Verification
gofmt,go vet, fullgo test -short ./...,make check-docs(regenerateddocs-gen/task.mdis committed in the same commit, as the gate requires), andsemgrep scan --config=auto --error .→ 0 findings. Rendered output read back from the built binary viatask run --help.Fixes #564
Refs #620, #565