Repository navigation
Run apps in the mounted persistent storage directory - #50
Conversation
Code Coverage Report - 46 of 115 lines covered ( ⛔ 40.00%)
⛔ This file is missing coverage.
|
There was a problem hiding this comment.
My comments:
Good stuff! A couple of requests (that aren't exactly related to this work!):
-
Out of scope based on the task, but do you mind adding quick documentation about the new way to access the PVC data externally at https://ad-apps-internal.fnal.gov/ap-python/files/ ? Note that the trailing slash is currently required
-
Could you please add a CHANGELOG? Based on conversation from other template repos, we've determined it's highly valuable for a template to have a changelog so that repos created from the template have a good way to know both (1) what template version their repo was created from (since they'll have a snapshot of the changelog at the time they made their repo) and (2) what updates they can bring in from the template as it improves
AI-assisted review:
Findings
1. major — Preserve permissions on existing host storage directories
Reference: Makefile:58–62, particularly chmod a+rwx.
The storage prerequisite unconditionally adds read, write, and search permissions for every host user to the selected directory, including existing directories supplied through STORAGE_HOST_DIR. Running a container or opening an image shell should not silently remove the privacy boundary of an existing host directory. Without a sticky bit, other local users who can traverse the parent directory can also remove or replace entries, even when the files themselves have restrictive modes.
Suggested fix: Preserve modes for existing directories and report incompatible access instead of broadening it. For newly created local storage, use ownership/group access or an explicitly opted-in permission policy; do not apply world-writable permissions indiscriminately to overrides.
Connor's comment: I'd change this just in case someone does run this locally rather than in a disposable dev container Update: not blocking based on in-person conversation with Jacob
2. minor — Resolve a relative writable-directory override before changing directory
Reference: docker/start.sh:27–30 and docker/start.sh:49–57.
The script accepts an existing relative writable-directory override and computes relative default log paths from it, then changes into that directory. Later log creation interprets those paths relative to the new working directory, effectively repeating the directory prefix. Startup exits before Xpra starts, even though the configured storage passed the initial existence and writability checks. The exported directory also remains relative to the changed working directory rather than identifying the validated directory.
Realistic trigger: Suppose the container starts in /mnt/storage/ap-python-writable, which contains a writable child directory named output, and the user sets AP_WRITABLE_STORAGE_DIR=output. The initial checks succeed. The script computes default log paths output/app.log and output/xpra.log, then changes into /mnt/storage/ap-python-writable/output. The later touch now targets /mnt/storage/ap-python-writable/output/output/app.log and /mnt/storage/ap-python-writable/output/output/xpra.log. Since the nested output directory does not exist, startup exits with status 1 before Xpra starts. The exported storage value also still says output, so application code resolving it from the new working directory would target that same unintended nested directory.
Suggested fix: After validating and entering the directory, replace the internal writable-directory value with the absolute current directory, then derive default log paths and export that resolved value. Alternatively, explicitly require and reject non-absolute values with a clear diagnostic.
Connor's comment: Not a blocker, but would be nice to fix
|
Update after in-person conversation with Jacob: we'll pass on AI finding #1 given how OS's handle subdirectory permissions |
Code Coverage Report - 46 of 115 lines covered ( ⛔ 40.00%)
⛔ This file is missing coverage.
|
|
Thanks for the review, Connor! I've added the changelog and updated the template version to 0.2.0. Also went ahead and added the note about the file read URL, so the docs are more complete |
chowington
left a comment
There was a problem hiding this comment.
Thanks, Jacob! Looks good 👍
Summary
Apps built from this template now run from the launcher's persistent volume,
/mnt/storage/ap-python-writable(the same path asAP_WRITABLE_STORAGE_DIR), instead of an arbitrary container directory. Localmaketargets mount a host directory at the same path so local runs behave like the launcher.Changes
Dockerfileruntimeandxpra-runtime) create/mnt/storage/ap-python-writable, chown it topyuser:pygroup, and set it asWORKDIR. This happens beforeUSER pyuser, so the directory is writable when no volume is mounted.docker/start.sh(GUI / Xpra image)WRITABLE_DIRdefaults fromAP_WRITABLE_STORAGE_DIR, falling back to/mnt/storage/ap-python-writable.app.logandxpra.lognow default to${WRITABLE_DIR}/…(previously/tmp).APP_LOG_FILEandXPRA_LOG_FILEstill override them.cds into it and exportsAP_WRITABLE_STORAGE_DIR, so the app launched by Xpra starts there./tmp.Makefilerun,run-gui,shellandshell-guibind-mountSTORAGE_HOST_DIR(defaultmount/<CONTAINER_NAME>/local) at/mnt/storage/ap-python-writableand setAP_WRITABLE_STORAGE_DIR.storage-dirtarget creates the host directory and makes it world-writable, because the container's UID 1000 may not match the host user.Other
.gitignoreignoresmount/.docs/container.md(new local storage mount section; removed stale/home/pyuserand/tmp/*.logstatements),docs/deployment.md,docs/application.md.README.md: notes that the Use this template button only appears when signed in to GitHub as a member of the Fermi-AD organization.Behavior changes to be aware of
/tmp/app.logand/tmp/xpra.logto the writable directory. They now persist.fsGroup), and the pod spec must not overrideworkingDir.Testing
make -n run run-gui shell shell-guishows the expecteddocker runcommands.bash -n docker/start.shpasses.make run,make run-gui, and a launch on the cluster.Migration for repositories already created from this template
Your repository has its own copy of these files, with names changed by the rename script, so don't overwrite them with the template versions. Apply the edits below by hand (or cherry-pick and resolve conflicts). Replace
<project>with your project name.Dockerfile: in both theruntimeandxpra-runtimestages, add the following immediately beforeUSER pyuser:pygroup:If you removed one of the stages, update only the one you kept.
docker/start.sh(only if you use thegui-xpraimage):In the "Application and logging settings" block, replace the two hardcoded log paths:
After the configuration block and before
cleanup(), add:Keep your own
APP_CMDandAPP_NAMEvalues. Don't copy those lines from the template.Makefile:Add these variables and add
storage-dirto.PHONY:Add the new target:
Make
run,run-gui,shellandshell-guidepend onstorage-dir, and add$(DOCKER_STORAGE_ARGS)to eachdocker runcommand..gitignore: addmount/if it isn't already ignored.Your application code:
/tmp,/home/pyuser,/app).Path(os.environ["AP_WRITABLE_STORAGE_DIR"]). Anything written elsewhere is lost when the launch ends./tmp./tmp/app.logor/tmp/xpra.log(scripts, docs, support runbooks) must use the new location.Docs (optional): copy the relevant changes from
docs/container.md,docs/deployment.mdanddocs/application.mdif your repository still carries the template docs.Verify, with Docker available:
No changes are needed to
.github/workflows/ci-cd.yaml. Merge tomainas usual to deliver. After delivery, confirm in the launcher that the app starts, can write toAP_WRITABLE_STORAGE_DIR, and (for the GUI) that logs appear in the launch's storage directory.