Skip to content

task: directory outputs (Manifest source ending in /) cannot work on the container path #564

Closed

Description

@scttfrdmn

Summary

recursiveFlag advertises directory staging — a Manifest whose Source ends in
/ gets aws s3 cp --recursive (pkg/taskproto/wrapper.go:288). For an
output on the container path, that form cannot work unless an input happens to
share the same directory. The tool fails to write before it produces anything.

This is the user-visible consequence of the gap already documented in the NOTE
above containerMountDirs — filing it separately because that note frames it as a
latent edge case, and it is actually "a documented output form that does not
function."

Mechanism (file:line)

Given outputs: [{source: "/tmp/out/", destination: "s3://.../out/"}]:

  1. path.Dir("/tmp/out/") is "/tmp/out" — verified against Go's path package,
    not assumed:
    path.Dir("/tmp/out/") = "/tmp/out"
    
    So containerMountDirs adds /tmp/out to the mount list
    (wrapper.go:264-280).
  2. The stage-in loop's mkdir -p iterates spec.Inputs only
    (wrapper.go:87). Nothing creates /tmp/out on the host.
  3. docker run -v /tmp/out:/tmp/out therefore auto-creates it — and dockerd does
    that as root, mode 0755.
  4. The container is not root. On v0.102.0 it runs as the image's own user
    (wrapper.go:233); after 4a8386f it runs as the invoking uid:gid. Either
    way it cannot write into a root-owned 0755 directory.
  5. The tool gets EACCES on its first write. And because stage-out's result is
    computed and discarded (Task path discards failure information: a lost output is reported as completed/exit 0, and a stage-in failure can produce no record at all #561), a task that produced nothing can still be
    recorded state: completed, exit_code: 0.

Measured, not inferred

This is the same failure mode the uid probe in #555 measured directly: with
destinations under /tmp/pw/out/, the probe reported Permission denied for a
root-owned output parent while /tmp itself succeeded. The probe also showed why
--user "$(id -u):$(id -g)" alone does not close this: it fixes input parents
(mode 0755, owned 1000:1000) and leaves output parents root-owned.

Why it matters more than it looks

Directory outputs are the natural shape for a large class of real work — any
aligner or profiler index (salmon index, STAR --runMode genomeGenerate,
bwa index, kallisto index) is a directory, not a file. Hitting this means
either discovering the mechanism above or concluding that spawn cannot ship an
index.

Also: examples/task-spec.json uses a nested layout, so the example every new user
copies first is on the failing side of this.

Suggested fix

Include output Source parents in the stage-in mkdir -p loop, alongside input
Destination parents — one loop over the same set containerMountDirs already
computes. That makes the dirs exist, owned by the invoking user, before
docker run can create them as root.

Mitigation in use

tar the directory into a single flat file under /tmp (mode 1777, the one
reliably writable mount), ship that, and untar in the consuming task. Working
examples: recipes/salmon/01-index.task.json and
recipes/star/01-index.task.json in scientific-codes-cookbook.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions