NatLabRockies / NatLabRockies/OpenStudio-server
Ensure analysis directory creation uses correct ownership/permissions
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 58
- Forks
- 27
- PR merge metrics
- No merged PRs in 30d
Description
Problem
The entrypoint script (docker/server/rails-entrypoint.sh) sets chmod 777 on parent directories (/mnt/openstudio/server/analyses, etc.) and sets umask 0000. However, there are concerns:
- No explicit ownership is set anywhere — ownership is entirely determined by the process UID at runtime
- Individual analysis subdirectories created at runtime by
FileUtils.mkdir_pinrun_simulate_data_point.rb:35-38inherit permissions from umask, but are never explicitly chmod'd - Known CI issue: The specs document that when running as root in Docker CI, root-owned
assets/analysesdirectories break later uploads by the unprivileged app user (analysis_init_spec.rblines 22-27) - No chown calls exist anywhere in the codebase
Current Behavior
- Entrypoint creates parent dirs with
chmod 777+umask 0000 - Runtime dirs rely solely on umask inheritance
- No verification that the running user can actually read/write the created directories
Proposed Fix
- In
rails-entrypoint.sh, ensure directories are owned by the correct user (e.g.,chown -R app:app /mnt/openstudioif running as non-root) - Consider adding an explicit
chmodaftermkdir_pcalls in the job runner to guarantee consistent permissions - Add a startup check that verifies the app user can write to the analyses directory
- Document the expected UID/GID for the container
Files to Modify
docker/server/rails-entrypoint.shserver/app/jobs/dj_jobs/run_simulate_data_point.rb- Potentially
Dockerfile(ensure USER directive is correct)
Related
Specs documenting the known issue: server/spec/models/analysis_init_spec.rb, server/spec/models/analyses_upload_spec.rb
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with docker/server/rails-entrypoint.sh and server/app/jobs/dj_jobs/run_simulate_data_point.rb:35-38, then read the documented cases in server/spec/models/analysis_init_spec.rb:22-27 and server/spec/models/analyses_upload_spec.rb. Done means the container-created analysis directories have predictable ownership and permissions, and the affected upload scenarios remain usable by the app user.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, ruby, shell
- Domain
- backend, devops, infrastructure, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100