forked from wseis/qmra
-
Notifications
You must be signed in to change notification settings - Fork 1
fix: refresh default treatments during deploy #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
yaniv-kwb
wants to merge
2
commits into
main
Choose a base branch
from
treatments_missing-bug
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,3 +12,5 @@ prod-migrations/ | |
| .vscode | ||
| test.zip | ||
| .vs | ||
| node_modules/ | ||
| *.log | ||
82 changes: 82 additions & 0 deletions
82
docs/superpowers/plans/2026-07-20-static-treatments-deploy-fix.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| # Static Treatments Deploy Fix Implementation Plan | ||
|
|
||
| > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. | ||
|
|
||
| **Goal:** Ensure admin-edited default treatments are exported into the shared static volume during deploy so the UI continues to read the latest treatments after a rollout. | ||
|
|
||
| **Architecture:** Keep the current browser flow intact: the frontend still loads `default-treatments.json` and merges it with the `/treatments` API response. Change only the deploy path so one init container runs `export_default` and then `collectstatic` in the same filesystem context, ensuring the generated JSON is copied into the shared static volume served by nginx. This avoids a backend API rewrite and keeps the fix limited to deployment plumbing. | ||
|
|
||
| **Tech Stack:** Django management commands, Helm init containers, Kubernetes persistent volumes, GitHub Actions Docker image build/deploy. | ||
|
|
||
| --- | ||
|
|
||
| ### Task 1: Verify the current deploy/data path | ||
|
|
||
| **Files:** | ||
| - Inspect: `infra/helm/qmra/templates/deployment.yaml` | ||
| - Inspect: `infra/helm/qmra/templates/volumes.yaml` | ||
| - Inspect: `infra/helm/qmra/templates/configmap.yaml` | ||
| - Inspect: `qmra/risk_assessment/admin.py` | ||
| - Inspect: `qmra/management/commands/export_default.py` | ||
|
|
||
| - [ ] **Step 1: Confirm where `export_default` writes** | ||
|
|
||
| Read `qmra/management/commands/export_default.py` and verify that `QMRATreatments.source` points at `qmra/static/data/default-treatments.json`. | ||
|
|
||
| - [ ] **Step 2: Confirm how the deploy mounts volumes** | ||
|
|
||
| Read `infra/helm/qmra/templates/deployment.yaml` and verify whether the `export-default` init container mounts the static PVC or only the `qmra-default` PVC. | ||
|
|
||
| - [ ] **Step 3: Confirm the static serving path** | ||
|
|
||
| Read `infra/helm/qmra/templates/volumes.yaml` and confirm that the nginx static deployment serves `/static` from the shared static PVC. | ||
|
|
||
| ### Task 2: Patch the deploy so the generated JSON survives into the static volume | ||
|
|
||
| **Files:** | ||
| - Modify: `infra/helm/qmra/templates/deployment.yaml` | ||
|
|
||
| - [ ] **Step 1: Combine export and collect into one init container** | ||
|
|
||
| Replace the separate `export-default` and `move-static` init containers with a single init container that mounts both shared volumes: | ||
|
|
||
| ```yaml | ||
| volumeMounts: | ||
| - name: qmra-default | ||
| mountPath: {{ .Values.qmra_default.mount_path }} | ||
| - name: static | ||
| mountPath: {{ .Values.static.mount_path }} | ||
| ``` | ||
|
|
||
| and runs: | ||
|
|
||
| ```yaml | ||
| command: [ sh, -c, "python manage.py export_default && python manage.py collectstatic --noinput" ] | ||
| ``` | ||
|
|
||
| This keeps the generated `qmra/static/data/default-treatments.json` visible to `collectstatic` before the init container exits. | ||
|
|
||
| ### Task 3: Validate the manifest and deployment flow | ||
|
|
||
| **Files:** | ||
| - Inspect: `infra/helm/qmra/templates/deployment.yaml` | ||
| - Inspect: `.github/workflows/deploy.yaml` | ||
|
|
||
| - [ ] **Step 1: Render the Helm template** | ||
|
|
||
| Run a template render or equivalent manifest check and confirm the `export-default` init container now has both the `qmra-default` and `static` mounts. | ||
|
|
||
| - [ ] **Step 2: Confirm workflow behavior** | ||
|
|
||
| Read `.github/workflows/deploy.yaml` and verify the image deployment path still uses the repository snapshot plus the runtime `helm upgrade`, so the updated manifest will be applied on the next deploy. | ||
|
|
||
| - [ ] **Step 3: Sanity-check the change** | ||
|
|
||
| Confirm there are no other changes to the treatment read path. The UI should still: | ||
|
|
||
| ```javascript | ||
| defaultTreatments = await fetch("{% static 'data/default-treatments.json' %}").then(resp => resp.json()); | ||
| defaultTreatments = {...defaultTreatments, ...await fetch("{% url 'treatments' %}").then(resp => resp.json())} | ||
| ``` | ||
|
|
||
| That behavior is intentional and should remain unchanged for this fix. |
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.