Skip to content

fix(taskproto): run task containers as the invoking uid:gid (#555) - #557

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/555-container-uid-mismatch
Sep 2, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/555-container-uid-mismatch

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Summary

  • spawn task run's container path staged inputs/outputs as the instance user (uid 1000 on AL2023, default umask -> 0755) but launched docker run with no --user, so the container ran as whatever USER the image declares. That's the default for the entire bioconda/conda-forge container ecosystem (every image built on mambaorg/micromamba defaults to uid 57439/mambauser) — any such task writing back into its staged directories got EACCES, surfacing only as an opaque stage-out failure.
  • docker run now passes --user "$(id -u):$(id -g)" so the container always runs as the uid:gid that owns the bind-mounted staging dirs, regardless of the image's declared USER. This is Option A from the issue, applied unconditionally with no opt-out flag — grepped examples/ for any task-spec relying on an image's own non-default USER (e.g. writing into $HOME or a conda prefix at runtime) and found none.
  • Documented, but did not fix (to avoid scope creep), a related latent gap: output-only directories not shared with any input are never mkdir -p'd on the host before docker run runs — see the comment above containerMountDirs in pkg/taskproto/wrapper.go.

Fixes #555

Test plan

  • New unit test TestGenerateWrapper_ContainerRunsAsInvokingUser asserts the generated wrapper text contains --user "$(id -u):$(id -g)" in the docker run line. Confirmed it fails against the pre-fix code (FAIL, missing string) and passes after the fix.
  • Stretch-goal test TestGenerateWrapper_ContainerRunLineExecutesWithRealUID extracts the actual generated docker run line and execs it for real under bash with stand-in sudo/docker PATH scripts, asserting the substituted --user value matches the real process's uid:gid (pattern borrowed from pkg/launcher/bootstrap_test.go's TestBuildLinuxBootstrap_ParamValueSurvivesRealShellParsing). Also confirmed fail-without/pass-with.
  • Updated the two existing container-path tests (TestGenerateWrapper_PrivateECRContainerWithGPU) whose exact-string assertion needed the new --user segment.
  • make check clean.
  • make check-docs clean (no flag/help text touched, no diff).
  • All 12 nested Go lambda/* modules build cleanly (github-oauth is Python, no go.mod).
  • CHANGELOG.md ## [Unreleased] / ### Fixed entry added, explicit that this affects the whole bioconda/conda-forge ecosystem, not one image.

@codecov

codecov Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

spawn task run's container path staged inputs/outputs as the instance
user (uid 1000 on AL2023, default umask -> 0755) but launched docker
run with no --user, so the container ran as whatever USER the image
declares. That's the default posture for the entire bioconda/
conda-forge container ecosystem (every image built on
mambaorg/micromamba defaults to uid 57439/mambauser), so any such task
writing back into its staged directories got EACCES, surfacing as an
opaque stage-out failure.

docker run now passes --user "$(id -u):$(id -g)" so the container
always runs as the uid:gid that owns the bind-mounted staging dirs,
regardless of the image's declared USER. Checked examples/ for any
task-spec example relying on an image's own non-default USER (e.g.
writing into $HOME or a conda prefix at runtime) and found none, so
this is applied unconditionally with no opt-out, matching the issue's
own preferred fix.

Also documents (without fixing, to avoid scope creep) a related latent
gap: output-only directories not shared with any input are never
mkdir'd on the host before docker run, so Docker's own auto-create of
a missing bind-mount source (owned by root) would still not be
writable even with --user set.
@scttfrdmn
scttfrdmn force-pushed the fix/555-container-uid-mismatch branch from 9987435 to 4a8386f Compare September 2, 2026 23:03
@scttfrdmn
scttfrdmn merged commit ac5655a into main Sep 2, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the fix/555-container-uid-mismatch branch September 2, 2026 23:13
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.

spawn task run: container can't write staged dirs when the image USER isn't root or uid 1000 (bioconda images are uid 57439)

1 participant