feat: add OCAP_TMP to redirect map-processing scratch off /tmp#487
Conversation
Map uploads fail on Pelican with "no space left on device" because the container's /tmp is too small for the maptool extraction and pipeline scratch (recording uploads are unaffected as they skip the pipeline). When OCAP_TMP is set, NewSetting creates it and points TMPDIR and CPL_TMPDIR at it. os.TempDir() re-reads TMPDIR per call and gdal/tippecanoe honor TMPDIR/CPL_TMPDIR, so a single redirect covers the upload temp file, extraction dir, pipeline working dirs, and subprocess scratch without touching the maptool code. Default unset preserves the current system-temp behavior. The Pelican egg sets OCAP_TMP to /home/container/tmp (persistent volume).
There was a problem hiding this comment.
Code Review
This pull request introduces a new configuration option OCAP_TMP (and tmp in config) to redirect the scratch/temporary space used for map uploads and processing away from the system /tmp directory. Feedback was provided to convert setting.Tmp to an absolute path using filepath.Abs before setting the environment variables TMPDIR and CPL_TMPDIR to prevent issues when subprocesses run in different working directories.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
A relative OCAP_TMP set raw into TMPDIR/CPL_TMPDIR would be resolved against each subprocess's own working dir (runCmdDir sets cmd.Dir), so gdal/tippecanoe scratch would land in the wrong place. filepath.Abs makes it cwd-independent. Adds a regression test for the relative-path case.
Drop the Pelican/too-small motivation (the PR and config docs already carry it); keep the non-obvious mechanism (single TMPDIR/CPL_TMPDIR redirect, abs-path requirement).
Merging this branch will not change overall coverage
Coverage by fileChanged files (no unit tests)
Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code. Changed unit test files
|
Problem
Map uploads fail on Pelican with
write /tmp/ocap-maptool-upload-*.zip: no space left on device. The container's/tmpis too small for the maptool scratch (ZIP extraction + DEM/contour/tile pipeline intermediates). Recording uploads are unaffected — they don't run the maptool pipeline.The reported error is just the first
/tmpwrite; the pipeline working dir (jobmanager.go) writes far larger intermediates there too.Fix
Add an
OCAP_TMPsetting. When set,NewSetting()creates the dir and pointsTMPDIR+CPL_TMPDIRat it at startup.A single redirect covers everything:
os.TempDir()re-reads$TMPDIRper call (Unix), and the four maptool temp sites useos.CreateTemp("")/os.MkdirTemp("")/os.TempDir().TMPDIR/CPL_TMPDIR, tippecanoe honorsTMPDIR, and subprocesses inherit the parent env (cmd.Envunset).So no changes were needed in
handler_maptool.goorjobmanager.go.Behavior
/tmp) — no change for existing standalone installs.OCAP_TMPdefaulting to/home/container/tmp(persistent volume); the app auto-creates it.OCAP_TMPstartup variable to/home/container/tmpand restart, without re-importing the egg.%TMP%/%TEMP%, notTMPDIR) — out of scope for the container case.Test plan
go build ./...,go vet ./internal/server/go test ./internal/server/ ./internal/maptool/passTestNewSetting_Tmp:OCAP_TMPcreates the dir and setsTMPDIR/CPL_TMPDIR; default-unset asserts emptyegg-ocap2-web.jsonandsetting.json.example