Stage concrete scratch under the build mount, not os.TempDir()
What does this MR do?
Stages the concrete executor's scratch (step scripts, archiver/cache staging,
helper-subprocess temp files) under the build mount instead of os.TempDir().
Concrete wrote its step scripts via os.CreateTemp("", ...), which resolves to
os.TempDir() and depends on whatever the runner process inherited as TMPDIR.
Abstract shell has always staged scratch under Build.TmpProjectDir() — a
sibling of BuildDir on the same volume — so scratch shares the build mount's
size, lifetime, and cleanup regardless of executor.
This MR makes concrete mirror that convention. At env construction it derives a
sibling-of-WorkingDir scratch directory (WorkingDir + ".tmp"), MkdirAlls
it, and then:
- writes the step script under it via
os.CreateTemp(e.TmpDir, ...), - defaults
e.StagingDirto it, so artifact staging follows the same convention when no explicitArchiverStagingDiroverride is supplied, - exports
TMPDIR=e.TmpDirandARCHIVER_STAGING_DIR=e.TmpDirto helper subprocesses viaHelperEnvs, soartifacts-downloader,cache-archiver,fastzipand friends land on the build mount too.
User script env is untouched: only HelperEnvs is augmented, so a user-set
TMPDIR keeps its value when the user's script runs.
Why was this MR needed?
Concrete diverged from abstract shell: scratch landed wherever the executor's
process-level TMPDIR pointed, which varies by deployment. The docker executor
on the production helper image (TMPDIR=/dev/shm, a tmpfs sized for the gRPC
socket) was where the divergence first surfaced as
write ...: no space left on device, but the same write-anywhere behaviour
applied to every other executor too — scratch could land off the build volume,
escaping its size limits, lifetime, and cleanup.
What's the best way to test this MR?
- Run a concrete job on the docker executor using the production helper image
(where
TMPDIR=/dev/shm) with a step that writes a non-trivial script and produces artifacts; confirm scratch is created under<build>.tmpand the job no longer hitsno space left on device. - Confirm a user-set
TMPDIRis still honoured inside the user script (only helper subprocesses get the runner'sTmpDir). go test ./functions/concrete/run/...
What are the relevant issue numbers?
Closes Bug when downloading artifacts with FF_CONCRETE... (#39475 - closed)