deploy-whakapapa: the #1311 readiness gate never gated (curl 000 + echo 000 = "000000" ≠ 000) — the owner user-add raced the entrypoint alembic migration and wedged Gramps Web on "table oidc_accounts already exists" (211 restarts); and the celery w… #1313

Closed
opened 2026-09-08 05:01:14 +00:00 by ben · 1 comment
Owner

Drive 20260908T035208Z (drive 8, #1277, on a0a1e58c): 16/17 green — archive + document-archive cycles proven again — deploy-whakapapa red at the 75 min ceiling (still running at 04:47Z; the switch never returned).

Evidence (read live off the run-19 guest)

  • grampsweb-admin.service FAILED at 04:21:19: grampsweb-admin: owner owner created but /api/token/ answers 000000 — the bootstrap did not take. Note the six zeros.
  • podman-grampsweb.service crash-looping — 211 restarts by 04:47 — every start dying in the image entrypoint's python3 -m alembic upgrade head: sqlite3.OperationalError: table oidc_accounts already exists on a8e57fe0d82e -> 2082445b0769.
  • podman-grampsweb-celery ran the SAME migration chain from empty at 04:21:18 (its journal shows every step) and hit the same already exists on the last one; it is active (running) now.
  • whakapapa-brand.service activating forever (its token loop), Caddy dial 127.0.0.1:8085 refused every 5 min, no failed units listed — the switch (clan-switch-gateway-*) still running.

Root cause — two faults, both in 3a2645a2 (#1311, mine)

  1. The readiness gate never gated. probe() was curl -s -o /dev/null -w '%{http_code}' … || echo 000. On a refused connection curl PRINTS 000 and exits non-zero, so the fallback appended a second 000 → "000000", which != 000 → the gate passed on its first tick, while the containers were still in their entrypoint migration. The user-add's create_app() then created the users-db tables (incl. oidc_accounts) from the models, and the in-flight alembic run collided with it — with SQLite's non-transactional DDL the table stays and alembic_version stays behind it, so EVERY restart replays the same failing step. A permanent wedge from a one-second race.
  2. Two migrators on one SQLite. The celery container runs the image's same /docker-entrypoint.sh (which runs alembic upgrade head regardless of cmd) against the shared /app/users/users.sqlite. Upstream's compose has the same shape and survives by luck; with fault 1 removed it is still a first-boot race between the API and the worker (dependsOn orders the UNIT — Type=notify, --sdnotify=conmon → active when conmon starts the container, not when gunicorn serves; pinned nixpkgs oci-containers.nix @173d0ad7 lines 388–548).

Fix (proposed ruling under ADR 0174 — two-way, veto anytime)

  • probe() captures curl's output and normalises it to exactly three digits (case "$code" in [0-9][0-9][0-9]) … ;; *) echo 000), no echo-on-failure fallback. Pin: the normaliser renders; the fallback never does.
  • grampsweb-celery gets dependsOn = [ "grampsweb-redis" "grampsweb" ] and an appended ExecStartPre (lib.mkAfter, after the module's own pre-start) that waits up to 300 s for GET /api/metadata/ on the serve port to answer any HTTP code — i.e. the API container's entrypoint has finished the migration and gunicorn serves — and exits 1 loudly otherwise (Restart=on-failure retries). One migrator at first boot, deterministic order.
  • GOTCHAS #188.

Also noted, not fixed here: run 18 (20260908T013813Z) hung 75 min on the same leg for a different reason — the drive host's Wi-Fi uplink dropped mid image pull and the container unit has TimeoutStartSec = 0 (the module's own default), so a silently stalled pull holds a deploy open until the harness ceiling.

Drive `20260908T035208Z` (drive 8, #1277, on `a0a1e58c`): 16/17 green — archive + document-archive cycles proven again — `deploy-whakapapa` red at the 75 min ceiling (still `running` at 04:47Z; the switch never returned). ## Evidence (read live off the run-19 guest) - `grampsweb-admin.service` FAILED at 04:21:19: `grampsweb-admin: owner owner created but /api/token/ answers 000000 — the bootstrap did not take`. Note the **six** zeros. - `podman-grampsweb.service` crash-looping — **211 restarts** by 04:47 — every start dying in the image entrypoint's `python3 -m alembic upgrade head`: `sqlite3.OperationalError: table oidc_accounts already exists` on `a8e57fe0d82e -> 2082445b0769`. - `podman-grampsweb-celery` ran the SAME migration chain from empty at 04:21:18 (its journal shows every step) and hit the same `already exists` on the last one; it is `active (running)` now. - `whakapapa-brand.service` `activating` forever (its token loop), Caddy `dial 127.0.0.1:8085 refused` every 5 min, no failed units listed — the switch (`clan-switch-gateway-*`) still running. ## Root cause — two faults, both in 3a2645a2 (#1311, mine) 1. **The readiness gate never gated.** `probe()` was `curl -s -o /dev/null -w '%{http_code}' … || echo 000`. On a refused connection curl PRINTS `000` **and** exits non-zero, so the fallback appended a second `000` → `"000000"`, which `!= 000` → the gate passed on its first tick, while the containers were still in their entrypoint migration. The user-add's `create_app()` then created the users-db tables (incl. `oidc_accounts`) from the models, and the in-flight alembic run collided with it — with SQLite's non-transactional DDL the table stays and `alembic_version` stays behind it, so EVERY restart replays the same failing step. A permanent wedge from a one-second race. 2. **Two migrators on one SQLite.** The celery container runs the image's same `/docker-entrypoint.sh` (which runs `alembic upgrade head` regardless of `cmd`) against the shared `/app/users/users.sqlite`. Upstream's compose has the same shape and survives by luck; with fault 1 removed it is still a first-boot race between the API and the worker (`dependsOn` orders the UNIT — `Type=notify`, `--sdnotify=conmon` → active when conmon starts the container, not when gunicorn serves; pinned nixpkgs `oci-containers.nix` @173d0ad7 lines 388–548). ## Fix (proposed ruling under ADR 0174 — two-way, veto anytime) - `probe()` captures curl's output and normalises it to exactly three digits (`case "$code" in [0-9][0-9][0-9]) … ;; *) echo 000`), no echo-on-failure fallback. Pin: the normaliser renders; the fallback never does. - `grampsweb-celery` gets `dependsOn = [ "grampsweb-redis" "grampsweb" ]` **and** an appended `ExecStartPre` (`lib.mkAfter`, after the module's own pre-start) that waits up to 300 s for `GET /api/metadata/` on the serve port to answer any HTTP code — i.e. the API container's entrypoint has finished the migration and gunicorn serves — and exits 1 loudly otherwise (`Restart=on-failure` retries). One migrator at first boot, deterministic order. - GOTCHAS #188. Also noted, not fixed here: run 18 (`20260908T013813Z`) hung 75 min on the same leg for a different reason — the drive host's Wi-Fi uplink dropped mid image pull and the container unit has `TimeoutStartSec = 0` (the module's own default), so a silently stalled pull holds a deploy open until the harness ceiling.
Author
Owner

Landed 729d81be (rebased on the #1312 lint fix a0a1e58c): probe normalised to three digits (pin forbids the echo-on-failure fallback); grampsweb-celery dependsOn the API container + appended ExecStartPre wait-for-serve (300 s, loud); GOTCHAS #188; STATUS lead. go test ./internal/clan/ green, rendered module parses (nix-instantiate --parse). Ruled two-way under ADR 0174 by the babysitting agent — veto anytime. Run 19 is still burning its ceiling on the wedged guest (ends ~05:36Z); the next fire on 729d81be is the proof.

Landed `729d81be` (rebased on the #1312 lint fix `a0a1e58c`): probe normalised to three digits (pin forbids the echo-on-failure fallback); `grampsweb-celery` `dependsOn` the API container + appended `ExecStartPre` wait-for-serve (300 s, loud); GOTCHAS #188; STATUS lead. `go test ./internal/clan/` green, rendered module parses (`nix-instantiate --parse`). Ruled two-way under ADR 0174 by the babysitting agent — veto anytime. Run 19 is still burning its ceiling on the wedged guest (ends ~05:36Z); the next fire on `729d81be` is the proof.
ben closed this issue 2026-09-08 05:02:30 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Matou/idss#1313
No description provided.