Skip to content

Commit 9bd7a43

Browse files
docs(operations): document the hot-reload webhook
Adds CFP_DATA_RELOAD_SECRET to the env-var table in deploy.md and a "Hot-reload webhook" section to runbook.md covering manual triggering and the response shapes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 8fdcbf3 commit 9bd7a43

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

docs/operations/deploy.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ comments. Production pod gets these mounted:
215215
| `CFP_DATA_REPO_PATH` | ConfigMap | `/app/data` (PVC mount) |
216216
| `CFP_DATA_REMOTE` | Secret | git URL (ssh in prod) |
217217
| `CFP_DATA_BRANCH` | ConfigMap | e.g. `fixture` / `main` |
218+
| `CFP_DATA_RELOAD_SECRET` | **Secret** | Shared bearer-token for the hot-reload webhook; when unset the `/api/_internal/reload-data` endpoint returns 503. See [runbook.md](runbook.md#hot-reload-webhook). |
218219
| `CFP_WEB_DIST_PATH` | ConfigMap | `/app/apps/web/dist` |
219220
| `STORAGE_BACKEND` | ConfigMap | `s3` (prod) / `filesystem` (sandbox) |
220221
| `CFP_PRIVATE_STORAGE_PATH` | ConfigMap | `/app/private-storage` (when filesystem) |

docs/operations/runbook.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,57 @@ The local working tree continues to accept writes — it's only the
9797
asynchronous mirror to GitHub that's broken. Once fixed, the daemon will
9898
push the backlog.
9999

100+
## Hot-reload webhook
101+
102+
The API exposes `POST /api/_internal/reload-data` so that a push to
103+
`CFP_DATA_BRANCH` (typically `published`) propagates to the running pod
104+
without rolling it. The `codeforphilly-data` repo's
105+
`notify-deployments.yml` workflow calls this endpoint on every push.
106+
107+
See [specs/behaviors/storage.md#hot-reload](../../specs/behaviors/storage.md#hot-reload)
108+
for the authoritative contract. Operationally:
109+
110+
- **Configured by** the `CFP_DATA_RELOAD_SECRET` env variable. When
111+
unset, the endpoint is still registered but returns 503 — the
112+
workflow's `curl` will exit non-zero and the operator must
113+
investigate. The secret value lives in the GitOps repo's
114+
`cfp-sandbox-cluster/codeforphilly-ng.secrets/` (or production
115+
equivalent) as a sealed Secret — not in the app repo.
116+
- **Trigger manually** for debugging:
117+
118+
```bash
119+
SECRET=$(kubectl -n codeforphilly-rewrite-sandbox get secret \
120+
codeforphilly-ng -o jsonpath='{.data.CFP_DATA_RELOAD_SECRET}' | base64 -d)
121+
122+
curl -sS -X POST https://next-v2.codeforphilly.org/api/_internal/reload-data \
123+
-H "Authorization: Bearer $SECRET" \
124+
-H "Content-Type: application/json" \
125+
-d '{}' | jq
126+
```
127+
128+
- **Response shapes** (all wrapped in the success envelope):
129+
- **No-op via cheap pre-check** (commit already in local HEAD) —
130+
`{ noChanges: true, outcome: 'in-sync', head, durationMs }`. No
131+
fetch, no lock acquired.
132+
- **No-op after reconcile** (local already matched remote after the
133+
fetch) — `{ noChanges: true, outcome: 'in-sync', oldCommit,
134+
newCommit, durationMs }`.
135+
- **Rebuilt** — `{ noChanges: false, rebuilt: true, outcome, oldCommit,
136+
newCommit, durationMs, conflictBranch? }`. `outcome` is one of
137+
`fast-forwarded`, `pushed-ahead`, `rebased`, `conflict-escaped`, or
138+
`fetch-failed` (see [`store/reconcile.ts`](../../apps/api/src/store/reconcile.ts)).
139+
- **500 response** means the reconcile happened but the in-memory
140+
rebuild threw partway. The pod's in-memory state and FTS index are
141+
in an undefined state — restart the pod:
142+
143+
```bash
144+
kubectl -n codeforphilly-rewrite-sandbox rollout restart deploy/codeforphilly
145+
```
146+
147+
- **Outside-the-pod observability** — every reload logs an info line
148+
with the outcome + commits; failures log error. Search the pod logs
149+
for `hot-reload` to audit the most recent firings.
150+
100151
## Helpful commands
101152

102153
```bash

0 commit comments

Comments
 (0)