Own-VPS gateway deploy races ourcloud-control-plane.service's post-supply restart, failing on a transient the unit already self-heals from #462

Closed
opened 2026-08-12 02:56:54 +00:00 by ben · 4 comments
Owner

Failure

Rehearsal drive 20260812T024144Z (rehearsal.idss.nz / droplet 134.199.163.178) red at leg control-plane (mislabeled supply in artifacts/legs.json — see below). error-context.md: journey leg "control-plane" went red: (no fault line rendered). App-level cause per logs/founding-state.log: deploying/deploy: gateway deploy failed — The gateway deploy failed. (full-install headline, internal/founding/deploy.go:616).

Evidence with file:line cites

  • test-results/drive-droplet/20260812T024144Z/artifacts/legs.json: leg supply marked red, but its own founding-state.log messages ("fleet software seeded onto the server — the control plane and dashboard are at their unit paths") show it succeeded. The label is an artifact of waitForLeg polling leg supply when the fault actually landed on the later leg control-plane (race comment at app/tests/e2e/fixtures/journey.ts:99-105).
  • logs/droplet-journal.txt:1143-1146: at boot (02:49:35), ourcloud-control-plane.service starts and immediately fails: ourcloud-control-plane-start: line 26: /srv/ourcloud/bin/control-plane: No such file or directory (exit 127) — the binary hasn't been scp'd in yet by fleetwire.Supply.Seed (internal/fleetwire/supply.go:53-96, run over a separate SSH channel, out-of-band from NixOS activation).
  • logs/droplet-journal.txt:1154-1236: the unit's Restart=on-failure/RestartSec=5s (declared at internal/clan/vmguest.go:344-345) retries and fails 6 times, 02:49:35→02:50:07 — this loop is the unit's designed tolerance for the race (see the ADR-0107 comment at internal/clan/vmguest.go:347-348: "the composition goes WHOLE only once seeding has pushed... before that it rests honestly").
  • logs/droplet-journal.txt:1238-1327: the app's gateway-deploy step invokes switch-to-configuration at 02:50:08-09, landing squarely inside that restart-loop window. It force-restarts the still-binary-less unit (droplet-journal.txt:1298-1304, same "No such file or directory"), and NixOS's switch-to-configuration treats a failed unit during activation as fatal: both switch attempts exit status 4/NOPERMISSION (droplet-journal.txt:1286-1287, 1326-1327) — this is what fails the whole deploy.
  • logs/droplet-journal.txt:1411-1436: the unit's own next scheduled restart succeeds cleanly just 4 seconds after the second failed switch attempt (02:50:17 vs 02:50:13) — full control-plane startup logs, no error. The deploy failed on a transient the unit already self-heals from moments later.

Suspected layer

Orchestration/timing between fleetwire.Supply.Seed (out-of-band scp of the control-plane binary, no systemd-visible completion signal) and the own-VPS full-install gateway-deploy trigger (switch-to-configuration, invoked from internal/founding/deploy.go's deploy flow), racing against ourcloud-control-plane.service's boot-time restart loop (internal/clan/vmguest.go:315-372, gatewayControlPlaneUnit). Not a rendering bug and not a wrong constant — it's a real infra-timing race on the droplet, not reproducible/verifiable from a Go/vitest unit test in this checkout.

What plugging it needs

A design decision among (at least):

  1. Have the deploy step verify (or wait for) the control-plane binary's presence on the guest before firing switch-to-configuration, instead of racing supply's scp.
  2. Gate ourcloud-control-plane.service's start with ConditionPathExists=/srv/ourcloud/bin/control-plane (skip cleanly pre-supply instead of failing) plus an explicit systemctl start ourcloud-control-plane issued at the end of Supply.Seed once the binary lands — so switch-to-configuration never observes a failed unit.
  3. Make the deploy trigger tolerate/retry once past this specific known-transient failure.

Secondary, non-blocking gap (do not let this substitute for the fix above)

readFault() (app/tests/e2e/fixtures/journey.ts:84-87) only reads [data-field="fault-line"], present only on the journey-fault panel. The deploy-failed panel (app/src/components/founding/FoundingDeployOutcome.vue:44-50, data-status="deploy-failed") renders data-field="failure-headline" instead, so every future deploy-stage failure will keep showing (no fault line rendered) in drive evidence and error-context.md, even though the droplet journal carries the real reason as shown above. Worth teaching the harness to also read failure-headline under [data-status="deploy-failed"], but that's cosmetic next to the race itself.

Note on recurrence

This run's signature (404124947736) previously resisted a heal on 20260811T183121Z (self-fixed via commit 99393f9d, an unrelated OWN_VPS_ORDER shape mismatch). That fix is confirmed present on main (commit 99393f9d27f12bf42244e90d51cb9cc15dacd504). This is a distinct, deeper root cause exposed only after that earlier bug stopped masking it.

drive 20260812T024144Z red at supply: journey leg "control-plane" went red: (no fault line rendered)
evidence: test-results/…/20260812T024144Z/ on matou-workstation (legs.json, droplet-journal.txt, trace)

## Failure Rehearsal drive `20260812T024144Z` (rehearsal.idss.nz / droplet 134.199.163.178) red at leg `control-plane` (mislabeled `supply` in `artifacts/legs.json` — see below). `error-context.md`: `journey leg "control-plane" went red: (no fault line rendered)`. App-level cause per `logs/founding-state.log`: `deploying/deploy: gateway deploy failed — The gateway deploy failed.` (full-install headline, `internal/founding/deploy.go:616`). ## Evidence with file:line cites - `test-results/drive-droplet/20260812T024144Z/artifacts/legs.json`: leg `supply` marked red, but its own founding-state.log messages (`"fleet software seeded onto the server — the control plane and dashboard are at their unit paths"`) show it succeeded. The label is an artifact of `waitForLeg` polling leg `supply` when the fault actually landed on the later leg `control-plane` (race comment at `app/tests/e2e/fixtures/journey.ts:99-105`). - `logs/droplet-journal.txt:1143-1146`: at boot (02:49:35), `ourcloud-control-plane.service` starts and immediately fails: `ourcloud-control-plane-start: line 26: /srv/ourcloud/bin/control-plane: No such file or directory` (exit 127) — the binary hasn't been scp'd in yet by `fleetwire.Supply.Seed` (`internal/fleetwire/supply.go:53-96`, run over a separate SSH channel, out-of-band from NixOS activation). - `logs/droplet-journal.txt:1154-1236`: the unit's `Restart=on-failure`/`RestartSec=5s` (declared at `internal/clan/vmguest.go:344-345`) retries and fails 6 times, 02:49:35→02:50:07 — this loop is the unit's *designed* tolerance for the race (see the ADR-0107 comment at `internal/clan/vmguest.go:347-348`: "the composition goes WHOLE only once seeding has pushed... before that it rests honestly"). - `logs/droplet-journal.txt:1238-1327`: the app's gateway-deploy step invokes `switch-to-configuration` at 02:50:08-09, landing squarely inside that restart-loop window. It force-restarts the still-binary-less unit (`droplet-journal.txt:1298-1304`, same "No such file or directory"), and NixOS's switch-to-configuration treats a failed unit during activation as fatal: **both** switch attempts exit `status 4/NOPERMISSION` (`droplet-journal.txt:1286-1287`, `1326-1327`) — this is what fails the whole deploy. - `logs/droplet-journal.txt:1411-1436`: the unit's own next scheduled restart succeeds cleanly just **4 seconds** after the second failed switch attempt (02:50:17 vs 02:50:13) — full control-plane startup logs, no error. The deploy failed on a transient the unit already self-heals from moments later. ## Suspected layer Orchestration/timing between `fleetwire.Supply.Seed` (out-of-band scp of the control-plane binary, no systemd-visible completion signal) and the own-VPS full-install gateway-deploy trigger (`switch-to-configuration`, invoked from `internal/founding/deploy.go`'s deploy flow), racing against `ourcloud-control-plane.service`'s boot-time restart loop (`internal/clan/vmguest.go:315-372`, `gatewayControlPlaneUnit`). Not a rendering bug and not a wrong constant — it's a real infra-timing race on the droplet, not reproducible/verifiable from a Go/vitest unit test in this checkout. ## What plugging it needs A design decision among (at least): 1. Have the deploy step verify (or wait for) the control-plane binary's presence on the guest before firing `switch-to-configuration`, instead of racing supply's scp. 2. Gate `ourcloud-control-plane.service`'s start with `ConditionPathExists=/srv/ourcloud/bin/control-plane` (skip cleanly pre-supply instead of failing) plus an explicit `systemctl start ourcloud-control-plane` issued at the end of `Supply.Seed` once the binary lands — so switch-to-configuration never observes a *failed* unit. 3. Make the deploy trigger tolerate/retry once past this specific known-transient failure. ## Secondary, non-blocking gap (do not let this substitute for the fix above) `readFault()` (`app/tests/e2e/fixtures/journey.ts:84-87`) only reads `[data-field="fault-line"]`, present only on the `journey-fault` panel. The deploy-failed panel (`app/src/components/founding/FoundingDeployOutcome.vue:44-50`, `data-status="deploy-failed"`) renders `data-field="failure-headline"` instead, so every future deploy-stage failure will keep showing `(no fault line rendered)` in drive evidence and error-context.md, even though the droplet journal carries the real reason as shown above. Worth teaching the harness to also read `failure-headline` under `[data-status="deploy-failed"]`, but that's cosmetic next to the race itself. ## Note on recurrence This run's signature (`404124947736`) previously resisted a heal on `20260811T183121Z` (self-fixed via commit `99393f9d`, an unrelated `OWN_VPS_ORDER` shape mismatch). That fix is confirmed present on `main` (commit `99393f9d27f12bf42244e90d51cb9cc15dacd504`). This is a distinct, deeper root cause exposed only after that earlier bug stopped masking it. drive `20260812T024144Z` red at `supply`: `journey leg "control-plane" went red: (no fault line rendered)` evidence: `test-results/…/20260812T024144Z/` on matou-workstation (legs.json, droplet-journal.txt, trace) <!-- rehearsal-sig: 404124947736 -->
Author
Owner

CORRECTION — this is NOT a transient race; it is a deterministic bogus-revision bug. Do not add a retry/wait — fix deployRevision.

The title framing (transient the unit self-heals from) is wrong: the deploy-time eval fails the SAME way every attempt, and #461 already added transient-retry to readinessAt which did not help — because this is a deterministic nix parse error, not a race. Reproduced below.


The own-VPS gateway deploy has never actually run — it is preflight-skipped every drive on a bogus revision

Surfaced by #461's Strict: true fix (drive 20260812T024144Z): the gateway deploy now fails loud with the real reason instead of silently succeeding —

founding-state.log:112-113
"headline": "The gateway deploy failed.",
"detail":   "error: unknown hash algorithm 'founding', expect 'blake3', 'md5', 'sha1', 'sha256', or 'sha512'"

Root cause

deployRevision (internal/founding/deploy.go:681) returns a placeholder that is not a git SHA:

func deployRevision(node clan.NodeID) string {
	return "founding-gateway-" + string(node)   // → "founding-gateway-gateway"
}

applyControlPlane passes it as DeployRequest.Revision, and flakeRef (internal/clan/adapter.go:442) turns a non-empty revision into a git flake ref:

func flakeRef(dir, revision string) string {
	if revision == "" { return "path:" + dir }
	return fmt.Sprintf("git+file://%s?rev=%s", dir, revision)
}

So readinessAt's eval (adapter.go:348) runs against git+file://<clan-config>?rev=founding-gateway-gateway, and nix parses founding-… as an SRI hash <algo>-<rest> → algorithm "founding" → error. readinessAt treats the non-zero exit as "node does not evaluate", and the deploy skips the node.

Proof (against this run's captured flake, no droplet)

nix eval --raw "git+file://<cfg>?rev=founding-gateway-gateway#nixosConfigurations.gateway.config.system.build.toplevel.drvPath"
→ error: unknown hash algorithm 'founding' …          EXIT=1     ← exact drive error

nix eval --raw "path:<cfg>#nixosConfigurations.gateway.config.system.build.toplevel.drvPath"
→ /nix/store/…-nixos-system-gateway-….drv             EXIT=0     ← rev="" evaluates cleanly

<cfg> = test-results/drive-droplet/20260812T024144Z/state/clan-config.

The config is valid; the revision is garbage. This means every own-VPS drive to date has preflight-skipped the deploy (before #461, silently; now, loudly). The control plane is present on the droplet only because the earlier nixos-anywhere install bakes it (droplet-journal.txt shows ourcloud-control-plane serving the OpenAPI API) — the deploy/reconcile step has been a no-op.

Fix

deployRevision should return "" for the founding/own-VPS deploy, so flakeRef uses path:<dir> — the correct reference for the locally-assembled clan-config (a path tree, not a git checkout at that rev), and the form proven to evaluate cleanly above. (A real committed git SHA would also be valid, but the assembled config isn't a git tree at that rev, so path: is the right choice.)

Confirm nothing else relies on the founding-gateway-<node> string (it appears to be a placeholder that never resolved). Rollback's revision-scope path is separate and unaffected.

Test

  • Unit: deployRevision returns "" (or a resolvable rev), and flakeRef(dir, deployRevision(n)) yields a path:/valid ref, never git+file://…?rev=founding-….
  • Seam/eval: readinessAt over the assembled clan-config for the single gateway node returns OK (reuses the eval-the-captured-seed harness from #401) — this would have red-lit the bogus rev without a droplet.
  • Regression: a single-node deploy whose node evaluates actually reaches clan machines update (the reconcile step runs), rather than landing in the skip path.

Advances #378. The next drive is the real reconcile — and if the deploy now runs, control-plane→dashboard→brand→admin→finish are the remaining legs.

**CORRECTION — this is NOT a transient race; it is a deterministic bogus-revision bug. Do not add a retry/wait — fix deployRevision.** The title framing (transient the unit self-heals from) is wrong: the deploy-time eval fails the SAME way every attempt, and #461 already added transient-retry to readinessAt which did not help — because this is a deterministic nix parse error, not a race. Reproduced below. --- ## The own-VPS gateway deploy has never actually run — it is preflight-skipped every drive on a bogus revision Surfaced by #461's `Strict: true` fix (drive `20260812T024144Z`): the gateway deploy now fails **loud** with the real reason instead of silently succeeding — ``` founding-state.log:112-113 "headline": "The gateway deploy failed.", "detail": "error: unknown hash algorithm 'founding', expect 'blake3', 'md5', 'sha1', 'sha256', or 'sha512'" ``` ## Root cause `deployRevision` (`internal/founding/deploy.go:681`) returns a placeholder that is not a git SHA: ```go func deployRevision(node clan.NodeID) string { return "founding-gateway-" + string(node) // → "founding-gateway-gateway" } ``` `applyControlPlane` passes it as `DeployRequest.Revision`, and `flakeRef` (`internal/clan/adapter.go:442`) turns a non-empty revision into a git flake ref: ```go func flakeRef(dir, revision string) string { if revision == "" { return "path:" + dir } return fmt.Sprintf("git+file://%s?rev=%s", dir, revision) } ``` So `readinessAt`'s eval (`adapter.go:348`) runs against `git+file://<clan-config>?rev=founding-gateway-gateway`, and nix parses `founding-…` as an SRI hash `<algo>-<rest>` → algorithm `"founding"` → error. `readinessAt` treats the non-zero exit as "node does not evaluate", and the deploy skips the node. ## Proof (against this run's captured flake, no droplet) ``` nix eval --raw "git+file://<cfg>?rev=founding-gateway-gateway#nixosConfigurations.gateway.config.system.build.toplevel.drvPath" → error: unknown hash algorithm 'founding' … EXIT=1 ← exact drive error nix eval --raw "path:<cfg>#nixosConfigurations.gateway.config.system.build.toplevel.drvPath" → /nix/store/…-nixos-system-gateway-….drv EXIT=0 ← rev="" evaluates cleanly ``` `<cfg>` = `test-results/drive-droplet/20260812T024144Z/state/clan-config`. The config is valid; the *revision* is garbage. This means **every own-VPS drive to date has preflight-skipped the deploy** (before #461, silently; now, loudly). The control plane is present on the droplet only because the earlier **nixos-anywhere install** bakes it (`droplet-journal.txt` shows `ourcloud-control-plane` serving the OpenAPI API) — the deploy/reconcile step has been a no-op. ## Fix `deployRevision` should return `""` for the founding/own-VPS deploy, so `flakeRef` uses `path:<dir>` — the correct reference for the locally-assembled clan-config (a path tree, not a git checkout at that rev), and the form proven to evaluate cleanly above. (A real committed git SHA would also be valid, but the assembled config isn't a git tree at that rev, so `path:` is the right choice.) Confirm nothing else relies on the `founding-gateway-<node>` string (it appears to be a placeholder that never resolved). `Rollback`'s revision-scope path is separate and unaffected. ## Test - Unit: `deployRevision` returns `""` (or a resolvable rev), and `flakeRef(dir, deployRevision(n))` yields a `path:`/valid ref, never `git+file://…?rev=founding-…`. - Seam/eval: `readinessAt` over the assembled clan-config for the single gateway node returns `OK` (reuses the eval-the-captured-seed harness from #401) — this would have red-lit the bogus rev without a droplet. - Regression: a single-node deploy whose node evaluates actually reaches `clan machines update` (the reconcile step runs), rather than landing in the skip path. Advances #378. The next drive is the real reconcile — and if the deploy now runs, control-plane→dashboard→brand→admin→finish are the remaining legs. <!-- rehearsal-sig: 404124947736 -->
Author
Owner

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

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

Implemented ben's ruling (the correction above: deterministic bogus-revision bug, not a transient race — fix deployRevision, no retry/wait).

Commit 327b968dd3235e0bcee28fe13d8443ed7b0c5d29 on main:

  • deployRevision() now returns "" so clan.flakeRef resolves the founding gateway deploy to path:<dir> (the locally-assembled clan-config is a path tree, not a git checkout at a rev), instead of git+file://…?rev=founding-gateway-<node> which nix rejected as unknown hash algorithm 'founding' — the eval failure readinessAt was reading as "node does not evaluate", preflight-skipping the only gateway node every own-VPS drive.
  • The one other caller, RepoHandover.Ref in the seeding push, is decoupled onto pushHandoverRef = "HEAD" (PushConfigRepo force-pushes HEAD and never reads the ref — HEAD is the honest provenance). Rollback's revision-scope path is separate and unaffected, as noted.
  • Tests: TestDeployRevision_EmptyForPathFlakeRef (revision empty, never the founding- placeholder) and TestStory26_… updated to the HEAD ref. go test ./internal/founding/... ./internal/fleetwire/... ./internal/clan/... green; golangci-lint/go vet/go build ./... clean.

The secondary readFault()/failure-headline harness gap is left as-is per the note (cosmetic, explicitly not a substitute for this fix). Advances #378 — the next own-VPS drive is the real reconcile.

**Implemented ben's ruling** (the correction above: deterministic bogus-revision bug, not a transient race — fix `deployRevision`, no retry/wait). Commit `327b968dd3235e0bcee28fe13d8443ed7b0c5d29` on `main`: - `deployRevision()` now returns `""` so `clan.flakeRef` resolves the founding gateway deploy to `path:<dir>` (the locally-assembled clan-config is a path tree, not a git checkout at a rev), instead of `git+file://…?rev=founding-gateway-<node>` which nix rejected as `unknown hash algorithm 'founding'` — the eval failure `readinessAt` was reading as "node does not evaluate", preflight-skipping the only gateway node every own-VPS drive. - The one other caller, `RepoHandover.Ref` in the seeding push, is decoupled onto `pushHandoverRef = "HEAD"` (PushConfigRepo force-pushes HEAD and never reads the ref — HEAD is the honest provenance). `Rollback`'s revision-scope path is separate and unaffected, as noted. - Tests: `TestDeployRevision_EmptyForPathFlakeRef` (revision empty, never the `founding-` placeholder) and `TestStory26_…` updated to the HEAD ref. `go test ./internal/founding/... ./internal/fleetwire/... ./internal/clan/...` green; golangci-lint/go vet/`go build ./...` clean. The secondary `readFault()`/`failure-headline` harness gap is left as-is per the note (cosmetic, explicitly not a substitute for this fix). Advances #378 — the next own-VPS drive is the real reconcile.
Author
Owner

close-report for #462 — status success

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

envelope
{
  "issue": 462,
  "status": "success",
  "commits": [
    "327b968dd3235e0bcee28fe13d8443ed7b0c5d29"
  ],
  "changed_files": [
    "STATUS.md",
    "internal/founding/deploy.go",
    "internal/founding/seed.go",
    "internal/founding/seed_test.go",
    "internal/founding/deployrevision_internal_test.go"
  ],
  "tests": [
    {
      "command": "nix develop .#go-ci -c go test ./internal/founding/... ./internal/fleetwire/... ./internal/clan/...",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci -c golangci-lint run ./internal/founding/...",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci -c go build ./...",
      "exit_code": 0
    }
  ],
  "criteria": {
    "deployRevision returns \"\" so flakeRef yields path:<dir>, never git+file://…?rev=founding-…": "internal/founding/deploy.go deployRevision() now returns \"\"; TestDeployRevision_EmptyForPathFlakeRef pins empty + never founding- prefix",
    "readinessAt over the single gateway node no longer preflight-skips on the bogus rev": "root cause was the rev feeding flakeRef; with \"\" flakeRef resolves to path:<dir> (clan.flakeRef adapter.go:442), the form ben proved evals clean (exit 0, real drvPath)",
    "nothing else relies on the founding-gateway-<node> string": "only other caller was RepoHandover.Ref (seed.go), decoupled onto pushHandoverRef=\"HEAD\" — PushConfigRepo (fleet.go) force-pushes HEAD and never reads repo.Ref; Rollback revision-scope path unaffected",
    "regression guards in place": "TestDeployRevision_EmptyForPathFlakeRef (new) + TestStory26_RepoPushedAuthorityFlipsReplicaReClones updated to assert the HEAD ref"
  },
  "summary": "deployRevision returns \"\" so the founding gateway deploy references the clan-config by path and evaluates, instead of preflight-skipping on a git+file rev nix rejected as hash algorithm 'founding'.",
  "blockers": []
}
**close-report** for #462 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; closing. <details><summary>envelope</summary> ```json { "issue": 462, "status": "success", "commits": [ "327b968dd3235e0bcee28fe13d8443ed7b0c5d29" ], "changed_files": [ "STATUS.md", "internal/founding/deploy.go", "internal/founding/seed.go", "internal/founding/seed_test.go", "internal/founding/deployrevision_internal_test.go" ], "tests": [ { "command": "nix develop .#go-ci -c go test ./internal/founding/... ./internal/fleetwire/... ./internal/clan/...", "exit_code": 0 }, { "command": "nix develop .#go-ci -c golangci-lint run ./internal/founding/...", "exit_code": 0 }, { "command": "nix develop .#go-ci -c go build ./...", "exit_code": 0 } ], "criteria": { "deployRevision returns \"\" so flakeRef yields path:<dir>, never git+file://…?rev=founding-…": "internal/founding/deploy.go deployRevision() now returns \"\"; TestDeployRevision_EmptyForPathFlakeRef pins empty + never founding- prefix", "readinessAt over the single gateway node no longer preflight-skips on the bogus rev": "root cause was the rev feeding flakeRef; with \"\" flakeRef resolves to path:<dir> (clan.flakeRef adapter.go:442), the form ben proved evals clean (exit 0, real drvPath)", "nothing else relies on the founding-gateway-<node> string": "only other caller was RepoHandover.Ref (seed.go), decoupled onto pushHandoverRef=\"HEAD\" — PushConfigRepo (fleet.go) force-pushes HEAD and never reads repo.Ref; Rollback revision-scope path unaffected", "regression guards in place": "TestDeployRevision_EmptyForPathFlakeRef (new) + TestStory26_RepoPushedAuthorityFlipsReplicaReClones updated to assert the HEAD ref" }, "summary": "deployRevision returns \"\" so the founding gateway deploy references the clan-config by path and evaluates, instead of preflight-skipping on a git+file rev nix rejected as hash algorithm 'founding'.", "blockers": [] } ``` </details>
ben closed this issue 2026-08-12 03:18:32 +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#462
No description provided.