Skip to content

feat: add OCAP_TMP to redirect map-processing scratch off /tmp#487

Merged
fank merged 3 commits into
mainfrom
claude/configurable-tmp-dir
Jun 22, 2026
Merged

feat: add OCAP_TMP to redirect map-processing scratch off /tmp#487
fank merged 3 commits into
mainfrom
claude/configurable-tmp-dir

Conversation

@fank

@fank fank commented Jun 22, 2026

Copy link
Copy Markdown
Member

Problem

Map uploads fail on Pelican with write /tmp/ocap-maptool-upload-*.zip: no space left on device. The container's /tmp is 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 /tmp write; the pipeline working dir (jobmanager.go) writes far larger intermediates there too.

Fix

Add an OCAP_TMP setting. When set, NewSetting() creates the dir and points TMPDIR + CPL_TMPDIR at it at startup.

A single redirect covers everything:

  • os.TempDir() re-reads $TMPDIR per call (Unix), and the four maptool temp sites use os.CreateTemp("") / os.MkdirTemp("") / os.TempDir().
  • gdal honors TMPDIR/CPL_TMPDIR, tippecanoe honors TMPDIR, and subprocesses inherit the parent env (cmd.Env unset).

So no changes were needed in handler_maptool.go or jobmanager.go.

Behavior

  • Default unset = system temp (/tmp) — no change for existing standalone installs.
  • Pelican egg ships an editable, required OCAP_TMP defaulting to /home/container/tmp (persistent volume); the app auto-creates it.
  • Existing Pelican servers can set the OCAP_TMP startup variable to /home/container/tmp and restart, without re-importing the egg.
  • Not covered: Windows (uses %TMP%/%TEMP%, not TMPDIR) — out of scope for the container case.

Test plan

  • go build ./..., go vet ./internal/server/
  • go test ./internal/server/ ./internal/maptool/ pass
  • New TestNewSetting_Tmp: OCAP_TMP creates the dir and sets TMPDIR/CPL_TMPDIR; default-unset asserts empty
  • JSON validity of egg-ocap2-web.json and setting.json.example

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).

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread internal/server/setting.go
fank added 2 commits June 22, 2026 11:18
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).
@fank fank marked this pull request as ready for review June 22, 2026 09:39
@fank fank merged commit cf3ca33 into main Jun 22, 2026
3 checks passed
@fank fank deleted the claude/configurable-tmp-dir branch June 22, 2026 09:39
@github-actions

Copy link
Copy Markdown

Merging this branch will not change overall coverage

Impacted Packages Coverage Δ 🤖
github.com/OCAP2/web/internal/server 93.82% (ø)

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/OCAP2/web/internal/server/setting.go 91.67% (ø) 84 77 7

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

  • github.com/OCAP2/web/internal/server/setting_test.go

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.

1 participant