Skip to content

fix(scripts): pre-create per-release hostPath dirs as host user - #67

Merged
saadqbal merged 1 commit into
developfrom
fix/per-release-hostpath-permissions
Apr 27, 2026
Merged

fix(scripts): pre-create per-release hostPath dirs as host user#67
saadqbal merged 1 commit into
developfrom
fix/per-release-hostpath-permissions

Conversation

@saadqbal

@saadqbalsaadqbal commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds _ensure_release_dirs <release> in scripts/lib/cluster.sh to pre-create $HOST_DATA_DIR/<release>/{data,logs,mysql} with mode 0777 owned by the host user.
  • Calls it from scripts/lib/install-client-helm.sh just before helm upgrade --install, where TB_NAMESPACE (= release name) is known in both the prompt and TRACEBLOC_VALUES_FILE dev-mode flows.

Why

The chart's hostPath PVs bind to /tracebloc/{{ .Release.Name }}/{data,logs,mysql} (see client/templates/shared-images-pvc.yaml, logs-pvc.yaml, mysql-storage-pvc.yaml), which maps back to $HOST_DATA_DIR/<release>/{data,logs,mysql} on the host through the k3d -v "${HOST_DATA_DIR}:/tracebloc@all" mount.

The existing _ensure_tracebloc_dirs only chmods $HOST_DATA_DIR/{data,logs,mysql} — a path the chart never touches. When the pod schedules, kubelet's DirectoryOrCreate creates the per-release subdirs as root:root mode 0755, leaving the host user (e.g. ubuntu on a typical EC2 box) unable to write there.

Repro (before this fix), with release ml-mrdan:

ubuntu@host:~$ ls -la ~/.tracebloc/ml-mrdan/data/
drwxr-xr-x 2 root root 4096 ... .
ubuntu@host:~$ echo test > ~/.tracebloc/ml-mrdan/data/test.txt
-bash: /home/ubuntu/.tracebloc/ml-mrdan/data/test.txt: Permission denied

After this fix, fresh installs pre-create the per-release dirs as the host user with 0777, so files dropped there appear at /data/shared inside the jobs-manager pod's api container as expected.

Notes

  • Existing installs where the per-release dirs already exist as root:root 0755 will need a one-time manual sudo chmod -R 777 ~/.tracebloc/<release>/{data,logs,mysql}. The chmod in the new function is best-effort (2>/dev/null || true) so re-running the installer won't error out, but it can't relax permissions on dirs the user doesn't own.
  • The existing _ensure_tracebloc_dirs is left untouched. Its chmod on $HOST_DATA_DIR/{data,logs,mysql} is a no-op for the chart but harmless and removing it is out of scope for this fix.

Test plan

  • bash -n syntax check on both modified files.
  • Sourced cluster.sh and ran _ensure_release_dirs ml-mrdan against a temp HOST_DATA_DIR — confirmed dirs created with mode 0777 owned by current user.
  • Empty release name short-circuits with exit 0 (defensive).
  • helm template ml-mrdan ./client --set hostPath.enabled=true ... confirms PV path: values are /tracebloc/ml-mrdan/{data,logs,mysql} — matches what the function pre-creates.
  • End-to-end: fresh scripts/install.sh on a clean EC2 box, verify ~/.tracebloc/<release>/data/test.txt written by host user appears in /data/shared/ of the jobs-manager pod.

🤖 Generated with Claude Code


Note

Low Risk
Low risk shell-script change limited to installer/cluster setup; main impact is filesystem permissions (creates/chmods release-specific dirs).

Overview
Fixes fresh installs where hostPath-backed volumes end up owned by root by pre-creating release-scoped directories on the host.

Adds _ensure_release_dirs <release> to create/chmod $HOST_DATA_DIR/<release>/{data,logs,mysql}, and calls it in install-client-helm.sh immediately before helm upgrade --install using TB_NAMESPACE as the release name.

Reviewed by Cursor Bugbot for commit b123cff. Bugbot is set up for automated code reviews on this repo. Configure here.

The chart's hostPath PVs bind to /tracebloc/<release>/{data,logs,mysql},
but the installer only chmodded /tracebloc/{data,logs,mysql} (no release
name). Result: kubelet's DirectoryOrCreate created the per-release subdirs
as root:root 0755 and the host user (e.g. ubuntu on EC2) could not drop
files into /data/shared via ~/.tracebloc/<release>/data.
Add _ensure_release_dirs(<release>) and call it just before
helm upgrade --install, so the dirs exist with permissive mode owned by
the host user before kubelet sees them.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@saadqbal
saadqbal merged commit 90e0155 into developApr 27, 2026
3 checks passed
@saadqbalsaadqbal self-assigned this Apr 28, 2026
@saadqbal
saadqbal deleted the fix/per-release-hostpath-permissions branch May 13, 2026 14:01
@LukasWodkaLukasWodka added bug Something isn't working work-type:bug Defect or regression labels Jun 8, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugSomething isn't workingwork-type:bugDefect or regression

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@saadqbal@divyasinghds@LukasWodka