File size: 9,947 Bytes
af1bee9 152e0c1 af1bee9 152e0c1 af1bee9 152e0c1 af1bee9 152e0c1 5ce1088 152e0c1 af1bee9 152e0c1 af1bee9 5ce1088 af1bee9 152e0c1 af1bee9 152e0c1 af1bee9 152e0c1 af1bee9 152e0c1 af1bee9 152e0c1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | # Runbook
Commands are for the container (the Space's terminal, `docker compose exec app ...` in Compose, or a local run).
`python -m coworker <command>` is the CLI.
## Daily checks
1. `/api/ready` answers `"ready": true`.
2. Settings > Storage and backups shows "Backups are working" and a recent save (hosts without a disk).
3. The runner's `https://<runner>/healthz` answers `"ok": true`, `"automation": true`, `"cases": true`, and the
`version` is the commit the Space runs.
4. Home: nothing unexpectedly "Waiting for you"; Settings > Schedules: no "The last start failed".
## Before every deploy or restart
A deploy or restart of the Space interrupts a running test run and loses anything not saved yet. Check right before,
not an hour before.
1. **No active work.** No run is running or queued (`GET /api/runs?status=running`, `?status=queued`), no pod is
reading its screens, and the runner's `/healthz` shows `"busy": false`. Wait for it to end, or cancel it.
2. **Save.** `POST /api/storage/save` as an administrator, and wait for the answer (`saved`, `last_saved_at`). 502 means
the save failed: do not restart until it works. From the Space's terminal: `python -m coworker state push`.
3. **Deploy or restart.**
4. **Update the runner** on the commit just deployed: `deploy/runner/sync.sh <ssh target> <ssh key> https://<runner>`.
It refuses while the runner is busy (exit 2); run it again when the run ends.
5. **Smoke test**: sign in, Test environments > Test connection, then a quick run on the Fusion pod.
## Incidents
| Symptom | What to do |
|---|---|
| The app does not start; log says `error parsing value for field "X"` | Fix setting X (the message names it); restart. |
| `/api/ready` is 503, `worker: false` | Restart the app (save first, above). Runs that were running become "interrupted": open each and press Resume. |
| A pod card says "interrupted by a server restart: read the screens again" | The restart cut off a screen read. Press Read screens on the pod's card, or let the next run read them. |
| A run stopped with "Pre-flight check failed, no browser was started" | Read the reason: the runner does not answer or has no scenario files (run `sync.sh`), or the test user cannot sign in. |
| A run or screen read failed with "the remote browser runner refused ... (HTTP 409 ...)" | The runner was busy with another job (one at a time). Resume the run, or read the screens again, when `/healthz` shows `"busy": false`. |
| A run failed with "The test browser stopped unexpectedly" | The browser host ran out of memory. Lower `FPT_FUSION_WORKERS`, run fewer areas at once, or give the runner more memory (REMOTE_RUNNER.md "Sizing"). |
| A run says "N test invoices were left on the Oracle Fusion pod" | The automatic clean-up could not reach Fusion. Cancel those invoice numbers in Fusion (Payables > Manage Invoices). |
| Test connection fails at "Sign-in" (HTTP 401) | The Fusion test user's password changed or the account is locked: fix it in Fusion, then Test environments > Sign-in details. Too many failed sign-ins lock Fusion users: do not retry in a loop. |
| A schedule switched itself off | It failed 3 times in a row; the reason is on the schedule. Fix the cause and switch it on again. |
| Someone must be stopped now | Settings > Emergency stop, or `python -m coworker kill --reason "..."`. Release with `unkill`. |
| A person is locked out of sign-in | Wait 5 minutes, or an admin resets their password in Settings > Users. |
| Suspected account compromise | Settings > Users: switch the account off (ends its sessions); rotate any secret it could see (SECURITY.md). |
| The audit log may have been altered | `python -m coworker verify-audit` (or `/api/audit/verify`): reports the first broken link. |
## Backups
**Host without a disk.** The app saves `state/latest.bin` to the bucket (OCI Object Storage when `OCI_STATE_PAR_URL` is
set, else Supabase Storage): when the data changed, at most every `FPT_STATE_SYNC_INTERVAL` seconds (at least 300 on
OCI); at once when a screen read finishes or a run waits for a person, ends or is cancelled; and on shutdown. The first
save of each process keeps the archive it found as `state/previous.bin`, and every save also keeps a copy as
`state/history/<time>.bin` (the newest `FPT_STATE_HISTORY`, default 5; older ones are deleted once an hour). If a
start-up restore fails, saving pauses (a notice in the app and `saved_state.paused` on `/api/ready`) so the good copy
is not overwritten.
`state/meta.json` carries a generation number and the instance that wrote it. Each start takes the next generation;
an older container that is still running (a Hugging Face rebuild keeps it up for a while) finds that at its next save
and stops saving: `saved_state.paused_reason` is `fenced`, the audit log has `state.fenced`, and the app shows
"Saving has stopped". Nothing to do: that container is the one being replaced. If it shows on the only running
instance, restart it (it restores the newer copy).
When the archive is over the size limit, evidence (then the folders of finished runs) is left out of it. Settings >
Storage says exactly what (`left_out_detail` on `/api/storage`), the audit log has `state.left_out`, and after a
restart those files answer 410 "not kept after a restart".
- Status: `python -m coworker state status` (prints `state/meta.json`: when, how big, why, what was left out)
- Save now: `POST /api/storage/save`, or `python -m coworker state push`
### Restore
The app restores at start when its data folder is empty, so a restore is: put the right archive in place as
`state/latest.bin`, then start a new container (a Space restart or a new deploy starts empty).
1. Stop the app (pause the Space) so it cannot save over the archive you are about to put back.
2. If the latest copy is bad, put `state/previous.bin` in place of `state/latest.bin`:
- **OCI Object Storage**: in the OCI console, open the bucket, download `state/previous.bin` and upload it as
`state/latest.bin`. Or with the pre-authenticated URL (keep it out of shell history and logs):
`curl -fsS -o previous.bin "$OCI_STATE_PAR_URL"state/previous.bin`, then
`curl -fsS -X PUT --data-binary @previous.bin "$OCI_STATE_PAR_URL"state/latest.bin`.
- **Supabase Storage**: in the Supabase dashboard, Storage > the bucket > `state/`: download `previous.bin` and
upload it as `latest.bin` (replace).
3. Start the app. Check the log line `state restored from the OCI bucket` (or `from Supabase Storage`), then sign in
and open a recent run.
4. If it says "the state archive cannot be decrypted with this key", `FPT_STATE_KEY` differs from the key the archive
was saved with: set the old key and restart.
### Going back to an earlier save (history)
1. Pick the copy: the names are in `saved_state.history` on `/api/storage` (newest first; Settings > Storage shows
how many) and in `state/meta.json`. The name is the save time in UTC, e.g. `state/history/20261118T101500Z.bin`.
2. Fence off the running app first, so none of its saves (its shutdown save included) lands on your copy: in
`state/meta.json` raise `generation` by one and set `instance` to `manual-restore`. Its next save is refused
(`state.fenced`). If the host can stop the app instead, stopping it before step 3 does the same.
3. In the bucket, copy that object over `state/latest.bin` (Supabase: download it and upload it as `latest.bin`; OCI:
console "Copy", or `curl -fsS -o copy.bin "$OCI_STATE_PAR_URL"state/history/<time>.bin`, then
`curl -fsS -X PUT --data-binary @copy.bin "$OCI_STATE_PAR_URL"state/latest.bin`).
4. Restart the app (Hugging Face: Restart, which starts with an empty data folder). It restores the copy and takes
the next generation. Anything saved after that copy is not restored; it stays in the newer history copies until
they age out.
**Compose.** `deploy/backup.sh /secure/backups`. Restore: stop the stack, put the archive's files back in the
`fpt-data` volume, start the stack. Keep backup archives encrypted: they contain the secrets vault in plain text.
## Upgrade and rollback
1. Follow "Before every deploy or restart" (above): nothing running, state saved.
2. Deploy the new image or upload the new revision. Migrations run at start (forward-only).
3. Update the runner with `sync.sh` on the same commit.
4. Smoke test: sign in, Test environments > Test connection, a quick run on the Fusion pod and approve it.
5. Rollback: deploy the previous image or Space revision and `sync.sh` that commit; if the release added a migration,
restore the snapshot taken before the upgrade first.
## Rotating secrets
Change the value in the platform's secret store, then restart (save first). Revoke the old key at its provider (NVIDIA,
Hugging Face, Supabase, OCI). For the Fusion test user, change the password in Fusion first. For the runner token,
change `RUNNER_TOKEN` on the runner and `FPT_SECRET_REMOTE_RUNNER_TOKEN` on the Space together.
`OCI_STATE_PAR_URL` grants access by itself: to rotate it, make a new pre-authenticated request on the bucket, set it,
restart, confirm a save, then delete the old request in the OCI console.
`FPT_STATE_KEY` is special: the snapshot is encrypted with it. To change it, `state push` with the old key, set the new
key, restart, and confirm a new save; keep the old key until the new save is confirmed.
## Retention
Screenshots, videos and traces: `EVIDENCE_RETENTION_DAYS` (30). Workflow checkpoints of finished runs:
`CHECKPOINT_RETENTION_DAYS` (7). Run folders: `RUN_FILES_RETENTION_DAYS` (90). Run records and the audit log are
kept. The clean-up runs daily from the scheduler; `python -m coworker purge` runs it now. On the runner, job folders
are deleted about `RUNNER_KEEP_HOURS` (24) after they start (REMOTE_RUNNER.md).
|