Skip to content

feat(taskproto): container /tmp is its own tmpfs; empty directory inputs fail stage-in (#1270, #1207) - #1282

Merged
scttfrdmn merged 1 commit into
mainfrom
feat/1270-1207-task-staging
Oct 24, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
feat/1270-1207-task-staging

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #1270
Fixes #1207

Two owner-approved behaviour changes in pkg/taskproto/wrapper.go.

#1270: a container task's /tmp

docker run now gets --tmpfs '/tmp:rw,exec,nosuid,nodev,mode=1777,size=50%'.

  • Size. size=50%: the kernel works it out when Docker mounts the tmpfs, on the instance, as half of RAM. systemd's tmp.mount sizes AL2023's host /tmp the same way. The wrapper has nothing to compute or parse, so it can't get the size wrong, and the line stays small for the user-data budget. I checked against Docker 29.9.2: df /tmp inside the container was exactly MemTotal/2.
  • exec. Docker's --tmpfs defaults to noexec. I checked this: without the flag the mount shows noexec, so a staged script or tool run from /tmp would fail. mode=1777 lets the non-root --user uid write.
  • Not the host's /tmp. The wrapper's record files and spored's signal files live there (recorddir.go, spawn#66). The container runs as the wrapper's own uid, so it could overwrite them.
  • Staged dirs under /tmp still show up. Docker mounts parents before children whatever order they appear in argv. I checked with a real docker run --tmpfs /tmp -v host:/tmp/in: the bind is visible on top of the tmpfs, writes reach the host, and the non-root user can write and exec in /tmp.
  • A manifest path directly in /tmp (for example /tmp/p2-task.sh). Today this makes /tmp itself a mount dir. I kept today's behaviour: host /tmp is bind-mounted and there is no --tmpfs. Docker refuses the pair: Duplicate mount point: /tmp (checked). The other option, binding each such file over the tmpfs, does not work for an output file that doesn't exist yet: Docker creates a missing bind source as a directory. Either way scratch is RAM-backed and half of RAM, because the host /tmp on AL2023 is that tmpfs. So the two cases behave the same except for what else is visible in /tmp.
  • command.log prints one line: either spawn: container /tmp is tmpfs, size=50% of RAM (N GiB) or spawn: container /tmp is the host /tmp (bind-mounted: a manifest path is directly in /tmp).
  • Caveat, also in the CHANGELOG: the host /tmp tmpfs (staged inputs) and the container's tmpfs each have a half-of-RAM cap. Together they can hold more than half of RAM, and pages written there are memory the workload can't use.

#1207: an empty or missing directory input

  • A directory input is one whose source ends in /. When one stages no regular file under its destination (find "$dest" -type f | head -n 1), stage-in fails: spawn: input s3://… copied no objects: the prefix is empty or missing (set allow_empty: true on this input if that is expected). It sets STAGE_RC=1 inside the input's existing if [ "$STAGE_RC" -eq 0 ] block. That is the same path a missing single object takes, so the record is failed / staging_error and the command does not run. The check is emitted as one shell function plus one line per input.
  • Folder markers. The CLI's own source (awscli 2.38.5, customizations/s3/filegenerator.py L367) only yields a key with Size == 0 that ends in / for delete. For a download it is skipped, so the most a marker-only prefix leaves behind is a directory. Counting -type f therefore treats it as empty. The test covers this with a stand-in that creates nested directories only.
  • Known limit. Two directory inputs can share one destination. If the first one filled it, an empty second prefix can't be detected. The check passes in that case, and the code comment says so.
  • New Manifest.AllowEmpty (allow_empty,omitempty) restores the old behaviour. Validate rejects it on a single-object input and on outputs.
  • Docs: spawn task run --help (and the regenerated docs-gen/task.md) and docs/workflow-adapter-protocol-rfc.md. api/public-surface.txt regenerated (one added field).

Gates (each watched failing against a revert that compiles)

Revert Failing test
tmpFlag = "" TestContainerTmpIsItsOwnTmpfs, TestContainerTmpfsReachesDockerRunArgv (exec, argv captured)
--tmpfs added even when /tmp is bind-mounted TestContainerTmpStaysHostBindWhenAManifestPathIsDirectlyInTmp
no empty check (checksEmptyDirInput → false) TestEmptyDirectoryInputFailsStageIn
shell function without STAGE_RC=1 TestEmptyDirectoryInputFailsStageIn
find -mindepth 1 (counts dirs) TestEmptyDirectoryInputFailsStageIn/folder_marker_only
allow_empty ignored TestDirectoryInputStagesWhenAllowedEmptyOrNonEmpty
Validate checks removed TestValidateAllowEmpty

runtimeStandInBin now also links find, head, awk and touch.

Wrapper size (gzip)

spec before after
trivial host (no inputs) 1764 1764
trivial container (no inputs) 2305 2424 (+119)
host + 1 directory input 1914 2049 (+135)
container + 1 directory input 2452 2699 (+247)

Checks

make check: fmt, vet, GOOS vet, staticcheck, golangci-lint (0 issues in 10 modules), hermetic tests and tidy all pass. Five nested lambda builds failed with ENOSPC because the internal disk was full; I re-ran their build, vet and test by hand and they pass. check-build-tags fails the same way on unmodified main (the /private/tmp path issue). make check-docs and semgrep scan --config=auto --error . are clean. Launcher and tasklaunch user-data budget tests pass.

Not verified: AL2023's own Docker package (25.x) with size=50% and exec. I tested only against Docker 29.9.2. moby passes the --tmpfs data options through to the kernel, which takes a % size.

…uts fail stage-in

(the size AL2023 gives the host's /tmp) instead of the image overlay on the root
disk. Staged directories under /tmp are mounted on top. A manifest path directly
in /tmp keeps the host /tmp bind mount (Docker refuses both on one path).
command.log says which.

fails stage-in as staging_error with a message naming the prefix. New per-input
field allow_empty restores the old behaviour; Validate rejects it on a file input
or an output.

Fixes #1270
Fixes #1207
@codecov

codecov Bot commented Oct 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn force-pushed the feat/1270-1207-task-staging branch from fc7f8fd to e026fb1 Compare October 24, 2026 01:38
@scttfrdmn
scttfrdmn merged commit 9eb2d64 into main Oct 24, 2026
9 checks passed
@scttfrdmn
scttfrdmn deleted the feat/1270-1207-task-staging branch October 24, 2026 01:58
@scttfrdmn scttfrdmn mentioned this pull request Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant