Guard against unwritable root-owned jobs/ directories#29
Merged
Conversation
The Pier Docker backend runs task containers as root and bind-mounts the jobs/ directory, so a completed run can leave jobs/ owned by root. A later run started as the normal user then cannot create a new run directory under it and Pier fails with a bare PermissionError. Add check_jobs_dir_writable() to pier_backend.py, which resolves the run directory Pier will create (jobs/<job-name>[/<run-id>]), finds the nearest existing ancestor, and raises PierBackendPreflightError with a chown remediation when it is not writable. Wire it into _validate_pier_specs so both `validate` and `run` surface a clear "jobs dir" check instead of an opaque traceback. Document the failure and fix in the scaffold README template and docs/collecting-run-data.md. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Running a freshly scaffolded experiment can fail with a bare
PermissionError: [Errno 13] Permission denied: '.../jobs/<job-name>'.The Pier Docker backend runs task containers as
rootand bind-mounts thejobs/directory, so a completed run can leavejobs/(and its contents) owned byroot. A subsequent run started as your normal user can no longer create a new run directory under it, and Pier surfaces only an opaquePermissionErrorwith no hint at the cause or the fix.What
check_jobs_dir_writable()inpier_backend.py. It resolves the run directory Pier will create (jobs/<job-name>[/<run-id>]), walks up to the nearest existing ancestor, and raisesPierBackendPreflightErrorwith an actionablesudo chown -R "$(id -u):$(id -g)" <dir>(orrm -rf) remediation when that ancestor is not writable._validate_pier_specs, so bothvalidateandrunreport a clearjobs dircheck and fail fast instead of crashing mid-run.README.md.tmpl(new Troubleshooting section) and indocs/collecting-run-data.md.Notes
writable=) so tests stay offline and do not depend on real uid/permissions (CI often runs as root, where a real chmod-based probe would misbehave).Testing
uv run ruff check .anduv run ruff format --check .clean.uv run pytest -qgreen, including three new tests covering the writable case, the nearest-existing-ancestor remediation message, and the CLI surfacing thejobs dircheck.