NatLabRockies / NatLabRockies/OpenStudio-server

Ensure analysis directory creation uses correct ownership/permissions

Open
#875 0 comments 0 reactions 0 assignees View on GitHub

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:

  1. No explicit ownership is set anywhere — ownership is entirely determined by the process UID at runtime
  2. Individual analysis subdirectories created at runtime by FileUtils.mkdir_p in run_simulate_data_point.rb:35-38 inherit permissions from umask, but are never explicitly chmod'd
  3. Known CI issue: The specs document that when running as root in Docker CI, root-owned assets/analyses directories break later uploads by the unprivileged app user (analysis_init_spec.rb lines 22-27)
  4. 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/openstudio if running as non-root)
  • Consider adding an explicit chmod after mkdir_p calls 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.sh
  • server/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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.