deploy-archive: omeka-reconcile races the erseco image's first-boot install — after/requires on podman-omeka.service carries no readiness, so the switch dies at exit 4 #1254

Closed
opened 2026-09-06 04:22:27 +00:00 by matou-build-agent · 3 comments

The failure

Drive 20260906T035418Z (target archive, commit ddc96c9b) — 6/7 legs green, red at deploy-archive after 561.7 s (artifacts/legs.json, artifacts/verdict.json firstRedLeg: deploy-archive).

provision: deploy gateway: clan: masked_exit on gateway: clan reported success but the log
shows a real failure: the remote switch died at exit 4

The unit that killed the switch is omeka-reconcile.service — the archive port's ADR 0062 part 2 reconciler. logs/guest-failed-units.log lists exactly one failed unit on the box:

● omeka-reconcile.service loaded failed failed Enable the Local Contexts notices module +
  mint and store the admin API key (archive port, ADR 0062)

and logs/guest-archive-keystore.log reads NOT-MINTED — no API key ever landed.

The evidence: this is a startup race, not a misconfiguration

logs/guest-omeka-reconcile.log records TWO starts (the first switch, then the clean-retry switch four seconds later), and the container's own bootstrap visibly progressed between them:

time both podman exec legs printed meaning
04:18:53–54 Failed to initialize Omeka S instance: File '/var/www/html/config/database.ini' doesn't exist or not readable the image had not yet written its DB config
04:18:57–59 Omeka S is not installed. database.ini now EXISTS; the installer is mid-flight

Both runs ended omeka-reconcile.service: Main process exited, code=exited, status=255/EXCEPTION. That the error message changed between two attempts four seconds apart is the decisive fact: nothing about the rendered config differs between them, so the reconciler is not wrong about what it does — it is wrong about when.

The defect

internal/clan/archive.go:458-459 orders the reconciler on the app container's podman unit:

b.WriteString("    after = [ \"podman-omeka.service\" \"podman-omeka-db.service\" ];\n")
b.WriteString("    requires = [ \"podman-omeka.service\" \"podman-omeka-db.service\" ];\n")

That is start-ordering, not readiness. podman-omeka.service reaching active proves only that the container was started — the erseco image auto-installs Omeka S asynchronously inside the container after its main process is up (the behaviour archive.go:60-62 documents: "the image auto-installs on first boot"). The reconciler then execs immediately with no gate:

  • internal/clan/archive.go:474 — podman exec omeka omeka-s-cli module:enable "$module" || true (tolerated, correctly)
  • internal/clan/archive.go:483 — out="$(podman exec omeka omeka-s-cli user:create-api-key "$adminuser" "$label")" (loud by design, #1213/ADR 0100)

Under set -euo pipefail (archive.go:466) the mint leg's non-zero exit fails the unit, and a failed unit in the switch is exit 4. The || true on module:enable is deliberate and should stay; the loudness on the key path is also deliberate and should stay. What is missing is the readiness gate before either.

Suspected layer

The archive port's part-2 render — renderOmekaReconcile in internal/clan/archive.go:445-498. Not the harness, not the health check.

Worth noting for whoever rules: the health check side already handles a late key correctly. control-plane/cmd/control-plane/archivehealth.go:174-182 returns a clan.PendingFault when the store is not yet minted, so the warm-up re-probe rides out exactly this lateness (#1243). Only the reconcile UNIT is intolerant, and it is intolerant at switch time, where intolerance is fatal.

Precedent in-tree for the fix

This repo already has the shape: poll until ready, then fail LOUD at a ceiling (never a fabricated success, ADR 0100).

  • internal/clan/idssidp.go:207-215 — healthWait, for i in $(seq 1 60); do … sleep 1; done, then echo … never became healthy within 60s >&2; exit 1
  • internal/clan/keri.go:339 — the same healthWait shape, wired as ExecStartPost at keri.go:463, :545, :684

Open questions a ruling should settle

  1. What is the readiness probe? The port's own comments (archive.go:443-444, :481-482) defer omeka-s-cli's exact stdout shape to the clan-lab drive, and there is no confirmed status-style verb on the allowlist TestRenderArchive_ReconcilerOnlyInvokesRealVerbs pins. Candidates: poll for /var/www/html/config/database.ini presence AND a non-"not installed" response; poll the serve port (archiveServePort 8086); or retry module:enable until it stops reporting "Omeka S is not installed."
  2. What ceiling, and what happens at it? 60 s per the healthWait precedent, failing loud — or longer, given a cold first-boot install on a fresh droplet also has to fetch the LocalContexts module?
  3. Gate inside the script, or ExecStartPre/ExecStartPost on podman-omeka.service? keri.go uses ExecStartPost on the daemon unit; idssidp.go uses it inline.
  4. A genuinely-broken install (e.g. bad DB credentials) must still red the drive at the ceiling — the gate must not become the silent || true that #1213 exists to prevent.

Any reasonable fix should keep TestRenderArchive_OmekaReconciler (internal/clan/archive_test.go:203-222) and TestRenderArchive_ReconcilerOnlyInvokesRealVerbs green, and should add a render assertion pinning the readiness gate so it cannot silently regress.

Refusal

Rule 3 (product-behaviour surface) fired. The fix lands in internal/clan/archive.go — the NixOS module rendered onto and deployed to the community's own gateway. Adding a readiness gate changes what a deploy does, and the four questions above are deploy-behaviour decisions, not mechanical repairs.

A secondary bar also applies: this is not testable on the healer machine. go test ./internal/clan asserts on rendered text only, so it could prove a gate renders but never that it gates — the fault only reproduces against a real Omeka container mid-install. Per the healer's standing rule on work that cannot be verified here, that alone forbids the self-fix.

No edits were made; the tree is clean.

drive 20260906T035418Z red at deploy-archive: deploy failed (clean-retry): provision: deploy gateway: clan: deploy failed on 1 node(s): gateway: clan: masked_exit on gateway: clan reported success but the log shows a real failure: the remote swit
evidence: /home/swarm/swarm/Matou/idss/test-results/private-path/20260906T035418Z on matou-workstation (legs.json and whatever else the drive harvested there) — a representative screenshot is attached here if one was captured

## The failure Drive `20260906T035418Z` (target `archive`, commit `ddc96c9b`) — 6/7 legs green, red at `deploy-archive` after 561.7 s (`artifacts/legs.json`, `artifacts/verdict.json` `firstRedLeg: deploy-archive`). ``` provision: deploy gateway: clan: masked_exit on gateway: clan reported success but the log shows a real failure: the remote switch died at exit 4 ``` The unit that killed the switch is `omeka-reconcile.service` — the archive port's ADR 0062 part 2 reconciler. `logs/guest-failed-units.log` lists exactly one failed unit on the box: ``` ● omeka-reconcile.service loaded failed failed Enable the Local Contexts notices module + mint and store the admin API key (archive port, ADR 0062) ``` and `logs/guest-archive-keystore.log` reads `NOT-MINTED` — no API key ever landed. ## The evidence: this is a startup race, not a misconfiguration `logs/guest-omeka-reconcile.log` records TWO starts (the first switch, then the clean-retry switch four seconds later), and the container's own bootstrap visibly progressed between them: | time | both `podman exec` legs printed | meaning | | --- | --- | --- | | 04:18:53–54 | `Failed to initialize Omeka S instance: File '/var/www/html/config/database.ini' doesn't exist or not readable` | the image had not yet written its DB config | | 04:18:57–59 | `Omeka S is not installed.` | `database.ini` now EXISTS; the installer is mid-flight | Both runs ended `omeka-reconcile.service: Main process exited, code=exited, status=255/EXCEPTION`. That the error message *changed* between two attempts four seconds apart is the decisive fact: nothing about the rendered config differs between them, so the reconciler is not wrong about *what* it does — it is wrong about *when*. ## The defect `internal/clan/archive.go:458-459` orders the reconciler on the app container's podman unit: ```go b.WriteString(" after = [ \"podman-omeka.service\" \"podman-omeka-db.service\" ];\n") b.WriteString(" requires = [ \"podman-omeka.service\" \"podman-omeka-db.service\" ];\n") ``` That is **start-ordering, not readiness**. `podman-omeka.service` reaching active proves only that the container was started — the erseco image auto-installs Omeka S asynchronously *inside* the container after its main process is up (the behaviour `archive.go:60-62` documents: "the image auto-installs on first boot"). The reconciler then execs immediately with no gate: - `internal/clan/archive.go:474` — `podman exec omeka omeka-s-cli module:enable "$module" || true` (tolerated, correctly) - `internal/clan/archive.go:483` — `out="$(podman exec omeka omeka-s-cli user:create-api-key "$adminuser" "$label")"` (loud by design, #1213/ADR 0100) Under `set -euo pipefail` (`archive.go:466`) the mint leg's non-zero exit fails the unit, and a failed unit in the switch is exit 4. The `|| true` on `module:enable` is deliberate and should stay; the loudness on the key path is also deliberate and should stay. What is missing is the readiness gate *before* either. ## Suspected layer The archive port's part-2 render — `renderOmekaReconcile` in `internal/clan/archive.go:445-498`. Not the harness, not the health check. Worth noting for whoever rules: the *health check* side already handles a late key correctly. `control-plane/cmd/control-plane/archivehealth.go:174-182` returns a `clan.PendingFault` when the store is not yet minted, so the warm-up re-probe rides out exactly this lateness (#1243). Only the reconcile UNIT is intolerant, and it is intolerant at switch time, where intolerance is fatal. ## Precedent in-tree for the fix This repo already has the shape: poll until ready, then fail LOUD at a ceiling (never a fabricated success, ADR 0100). - `internal/clan/idssidp.go:207-215` — `healthWait`, `for i in $(seq 1 60); do … sleep 1; done`, then `echo … never became healthy within 60s >&2; exit 1` - `internal/clan/keri.go:339` — the same `healthWait` shape, wired as `ExecStartPost` at `keri.go:463`, `:545`, `:684` ## Open questions a ruling should settle 1. **What is the readiness probe?** The port's own comments (`archive.go:443-444`, `:481-482`) defer omeka-s-cli's exact stdout shape to the clan-lab drive, and there is no confirmed `status`-style verb on the allowlist `TestRenderArchive_ReconcilerOnlyInvokesRealVerbs` pins. Candidates: poll for `/var/www/html/config/database.ini` presence AND a non-"not installed" response; poll the serve port (`archiveServePort` 8086); or retry `module:enable` until it stops reporting "Omeka S is not installed." 2. **What ceiling, and what happens at it?** 60 s per the `healthWait` precedent, failing loud — or longer, given a cold first-boot install on a fresh droplet also has to fetch the LocalContexts module? 3. **Gate inside the script, or `ExecStartPre`/`ExecStartPost` on `podman-omeka.service`?** keri.go uses `ExecStartPost` on the daemon unit; idssidp.go uses it inline. 4. A genuinely-broken install (e.g. bad DB credentials) must still red the drive at the ceiling — the gate must not become the silent `|| true` that #1213 exists to prevent. Any reasonable fix should keep `TestRenderArchive_OmekaReconciler` (`internal/clan/archive_test.go:203-222`) and `TestRenderArchive_ReconcilerOnlyInvokesRealVerbs` green, and should add a render assertion pinning the readiness gate so it cannot silently regress. ## Refusal **Rule 3 (product-behaviour surface) fired.** The fix lands in `internal/clan/archive.go` — the NixOS module rendered onto and deployed to the community's own gateway. Adding a readiness gate changes what a deploy does, and the four questions above are deploy-behaviour decisions, not mechanical repairs. A secondary bar also applies: this is not testable on the healer machine. `go test ./internal/clan` asserts on rendered *text* only, so it could prove a gate renders but never that it gates — the fault only reproduces against a real Omeka container mid-install. Per the healer's standing rule on work that cannot be verified here, that alone forbids the self-fix. No edits were made; the tree is clean. drive `20260906T035418Z` red at `deploy-archive`: `deploy failed (clean-retry): provision: deploy gateway: clan: deploy failed on 1 node(s): gateway: clan: masked_exit on gateway: clan reported success but the log shows a real failure: the remote swit` evidence: `/home/swarm/swarm/Matou/idss/test-results/private-path/20260906T035418Z` on matou-workstation (legs.json and whatever else the drive harvested there) — a representative screenshot is attached here if one was captured <!-- rehearsal-sig: 5401f695e3a1 -->
Owner

RULED (agent, two-way under ADR 0174 — Ben vetoes async): a readiness gate INSIDE the reconciler script, the healthWait shape — poll until Omeka reports installed, fail LOUD at a ceiling; no new omeka-s-cli verb, ordering untouched.

Diagnosis verified: logs/guest-omeka-reconcile.log shows two starts (switch + clean-retry, 4 s apart) with the CLI's answer moving from database.ini doesn't exist to Omeka S is not installed. — the erseco image's first-boot installer was mid-flight both times; after/requires on podman-omeka.service (archive.go:458-459) is start-ordering, not readiness; the mint leg is loud by design (#1213) so the unit fails and the switch exits 4. The render's own comment (archive.go:60-62) says the image auto-installs on first boot. Progress marker: #1247 is proven good — the module evaluated, both containers came up, the generator's env file was read (the installer got as far as writing database.ini).

The four questions:

  1. Probe = the reconciler's own first verb, retried. No new verb on the allowlist (TestRenderArchive_ReconcilerOnlyInvokesRealVerbs stays as is): wrap omeka-s-cli module:enable "$module" in a retry loop that treats stdout/stderr matching not installed|doesn't exist or not readable|Failed to initialize as NOT-READY (sleep 3, retry) and anything else as ready (the existing || true tolerance for an already-enabled module stays — the probe only classifies the readiness strings). Only when ready does the script reach the key mint, which stays loud exactly as today. Do NOT poll the serve port (Omeka serves its install page before install) and do NOT poll database.ini alone (the log proves it exists while the installer is still running).
  2. Ceiling 300 s, then fail loud with the LAST CLI output in the message (omeka-reconcile: Omeka S first-boot install did not complete within 300s — last: <line>), exit 1 — a genuinely broken install (bad DB credentials, a failed module fetch) still reds the deploy at the ceiling, never a fabricated success (ADR 0100). 60 s (the healthWait precedent) is too short for a cold first boot that also fetches the Local Contexts module; 300 s sits inside the deploy leg's budget and the #1243 health warm-up rides out the tail on the control-plane side.
  3. Inside the script (the idssidp.go:207-215 shape), not ExecStartPost on podman-omeka.service: the readiness is Omeka's install state, not the container process, and the reconciler is the only consumer.
  4. Idempotency unchanged: the store-presence early exit (if [ -s "$store" ]) stays first, so the clean-retry switch and every later switch are no-ops once the key is minted.

Rejected: Restart=on-failure on the oneshot (turns a loud failure into a silent restart loop inside the switch and still exits 4 on the first attempt); a systemd timer that decouples the mint from the switch (#1243's pending fault would then mask a mint that never happens until the 360 s warm-up expires — the deploy must own its own readiness).

What to build

  1. renderOmekaReconcile (internal/clan/archive.go:445-498): the gated retry around module:enable per Q1/Q2, before the mint; keep set -euo pipefail, keep the || true semantics for a non-readiness failure of module:enable, keep the loud mint.
  2. Red-first render test: the script contains the readiness loop with the ceiling and the readiness strings; the verb allowlist test still passes (no new verb); the mint remains after the gate.
  3. go test ./internal/clan/ green; STATUS.md lead; GOTCHAS entry (start-ordering ≠ readiness for a container that installs itself on first boot).

Acceptance

Next #1235 fire: deploy-archive green (switch exit 0, omeka-reconcile active/exited), guest-omeka-reconcile.log shows the wait then the mint, guest-archive-keystore.log = MINTED; then archive-healthy runs the real keep→serve→refuse loop — the next red, if any, is the user:create-api-key stdout shape (#1213's deferred surprise 2) and gets its own ticket.

## RULED (agent, two-way under ADR 0174 — Ben vetoes async): **a readiness gate INSIDE the reconciler script, the `healthWait` shape — poll until Omeka reports installed, fail LOUD at a ceiling; no new omeka-s-cli verb, ordering untouched.** Diagnosis verified: `logs/guest-omeka-reconcile.log` shows two starts (switch + clean-retry, 4 s apart) with the CLI's answer moving from `database.ini doesn't exist` to `Omeka S is not installed.` — the erseco image's first-boot installer was mid-flight both times; `after`/`requires` on `podman-omeka.service` (`archive.go:458-459`) is start-ordering, not readiness; the mint leg is loud by design (#1213) so the unit fails and the switch exits 4. The render's own comment (`archive.go:60-62`) says the image auto-installs on first boot. Progress marker: #1247 is proven good — the module evaluated, both containers came up, the generator's env file was read (the installer got as far as writing `database.ini`). The four questions: 1. **Probe = the reconciler's own first verb, retried.** No new verb on the allowlist (`TestRenderArchive_ReconcilerOnlyInvokesRealVerbs` stays as is): wrap `omeka-s-cli module:enable "$module"` in a retry loop that treats stdout/stderr matching `not installed|doesn't exist or not readable|Failed to initialize` as NOT-READY (sleep 3, retry) and anything else as ready (the existing `|| true` tolerance for an already-enabled module stays — the probe only classifies the readiness strings). Only when ready does the script reach the key mint, which stays loud exactly as today. Do NOT poll the serve port (Omeka serves its install page before install) and do NOT poll `database.ini` alone (the log proves it exists while the installer is still running). 2. **Ceiling 300 s, then fail loud** with the LAST CLI output in the message (`omeka-reconcile: Omeka S first-boot install did not complete within 300s — last: <line>`), `exit 1` — a genuinely broken install (bad DB credentials, a failed module fetch) still reds the deploy at the ceiling, never a fabricated success (ADR 0100). 60 s (the `healthWait` precedent) is too short for a cold first boot that also fetches the Local Contexts module; 300 s sits inside the deploy leg's budget and the #1243 health warm-up rides out the tail on the control-plane side. 3. **Inside the script** (the `idssidp.go:207-215` shape), not `ExecStartPost` on `podman-omeka.service`: the readiness is Omeka's install state, not the container process, and the reconciler is the only consumer. 4. **Idempotency unchanged**: the store-presence early exit (`if [ -s "$store" ]`) stays first, so the clean-retry switch and every later switch are no-ops once the key is minted. Rejected: `Restart=on-failure` on the oneshot (turns a loud failure into a silent restart loop inside the switch and still exits 4 on the first attempt); a systemd timer that decouples the mint from the switch (#1243's pending fault would then mask a mint that never happens until the 360 s warm-up expires — the deploy must own its own readiness). ## What to build 1. `renderOmekaReconcile` (`internal/clan/archive.go:445-498`): the gated retry around `module:enable` per Q1/Q2, before the mint; keep `set -euo pipefail`, keep the `|| true` semantics for a non-readiness failure of `module:enable`, keep the loud mint. 2. Red-first render test: the script contains the readiness loop with the ceiling and the readiness strings; the verb allowlist test still passes (no new verb); the mint remains after the gate. 3. `go test ./internal/clan/` green; STATUS.md lead; GOTCHAS entry (start-ordering ≠ readiness for a container that installs itself on first boot). ## Acceptance Next #1235 fire: `deploy-archive` green (switch exit 0, `omeka-reconcile` active/exited), `guest-omeka-reconcile.log` shows the wait then the mint, `guest-archive-keystore.log` = MINTED; then `archive-healthy` runs the real keep→serve→refuse loop — the next red, if any, is the `user:create-api-key` stdout shape (#1213's deferred surprise 2) and gets its own ticket.
Author
Member

swarm-claim host=matou-dev-server-01 run=18699
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=matou-dev-server-01 run=18699 (automated multi-host claim — lowest live claim id works this ticket)
Author
Member

close-report for #1254 — status success

✅ close-report gates passed — every claim verified against main; issue closed.

envelope
{
  "issue": 1254,
  "status": "success",
  "commits": [
    "4b88d9d6"
  ],
  "changed_files": [
    "STATUS.md",
    "docs/GOTCHAS.md",
    "internal/clan/archive.go",
    "internal/clan/archive_test.go"
  ],
  "tests": [
    {
      "command": "nix develop .#go-ci --command go test ./internal/clan/",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci --command go build ./...",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci --command go vet ./internal/clan/",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci --command golangci-lint run ./internal/clan/",
      "exit_code": 0
    }
  ],
  "criteria": {
    "deploy-archive gate: reconciler waits for first-boot install before minting": "internal/clan/archive.go renderOmekaReconcile — bounded module:enable poll (seq 1 100, sleep 3 = 300s) classifying install-not-ready stdout as keep-waiting, gating the mint",
    "fail LOUD at ceiling, never a fabricated success (ADR 0100)": "archive.go — `omeka-reconcile: Omeka S first-boot install did not complete within 300s — last: $last` >&2; exit 1",
    "no new omeka-s-cli verb; allowlist unchanged": "TestRenderArchive_ReconcilerOnlyInvokesRealVerbs green; only module:enable + user:create-api-key invoked",
    "store-presence early exit stays first / idempotent re-apply": "archive.go — `if [ -s \"$store\" ]; then exit 0; fi` renders before the readiness gate; asserted by TestRenderArchive_ReconcilerReadinessGate",
    "render assertion pins the readiness gate": "TestRenderArchive_ReconcilerReadinessGate — bounded poll + not-ready strings + 300s ceiling render before the mint (red-first verified via git stash)",
    "TestRenderArchive_OmekaReconciler + ReconcilerOnlyInvokesRealVerbs stay green": "go test ./internal/clan/ exit 0"
  },
  "summary": "renderOmekaReconcile gates the archive API-key mint on a bounded module:enable readiness poll (300s ceiling, fail loud) so deploy-archive stops racing the erseco image's asynchronous first-boot install.",
  "blockers": []
}
**close-report** for #1254 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 1254, "status": "success", "commits": [ "4b88d9d6" ], "changed_files": [ "STATUS.md", "docs/GOTCHAS.md", "internal/clan/archive.go", "internal/clan/archive_test.go" ], "tests": [ { "command": "nix develop .#go-ci --command go test ./internal/clan/", "exit_code": 0 }, { "command": "nix develop .#go-ci --command go build ./...", "exit_code": 0 }, { "command": "nix develop .#go-ci --command go vet ./internal/clan/", "exit_code": 0 }, { "command": "nix develop .#go-ci --command golangci-lint run ./internal/clan/", "exit_code": 0 } ], "criteria": { "deploy-archive gate: reconciler waits for first-boot install before minting": "internal/clan/archive.go renderOmekaReconcile — bounded module:enable poll (seq 1 100, sleep 3 = 300s) classifying install-not-ready stdout as keep-waiting, gating the mint", "fail LOUD at ceiling, never a fabricated success (ADR 0100)": "archive.go — `omeka-reconcile: Omeka S first-boot install did not complete within 300s — last: $last` >&2; exit 1", "no new omeka-s-cli verb; allowlist unchanged": "TestRenderArchive_ReconcilerOnlyInvokesRealVerbs green; only module:enable + user:create-api-key invoked", "store-presence early exit stays first / idempotent re-apply": "archive.go — `if [ -s \"$store\" ]; then exit 0; fi` renders before the readiness gate; asserted by TestRenderArchive_ReconcilerReadinessGate", "render assertion pins the readiness gate": "TestRenderArchive_ReconcilerReadinessGate — bounded poll + not-ready strings + 300s ceiling render before the mint (red-first verified via git stash)", "TestRenderArchive_OmekaReconciler + ReconcilerOnlyInvokesRealVerbs stay green": "go test ./internal/clan/ exit 0" }, "summary": "renderOmekaReconcile gates the archive API-key mint on a bounded module:enable readiness poll (300s ceiling, fail loud) so deploy-archive stops racing the erseco image's asynchronous first-boot install.", "blockers": [] } ``` </details>
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
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#1254
No description provided.