deploy-takeover: kanidm post-start cannot read root-owned files-oidc-secret (0400) #1097

Closed
opened 2026-09-01 02:57:08 +00:00 by matou-build-agent · 1 comment

The failure

deploy-takeover is the only red leg (26/27 green; verdict.json → "firstRedLeg": "deploy-takeover", skip: 0). This is not the known own-VPS pairing frontier — pair is green (157 ms) and legs.json carries no skip reasons at all.

The takeover deploy adds the nextcloud OAuth2 client to kanidm (ADR 0210, files off-gateway). kanidm's ExecStartPost provisioner (kanidm-provision) creates the client, then dies reading the shared basic secret. That kills kanidm.service → files-idp-client.service then burns its whole 5-minute settle budget against a dead kanidm → switch-to-configuration exits 4 → the drive's masked-exit detector fires.

Evidence

Root cause, logs/gateway-journal.txt:1354-1404 (repeats identically at :1733-1757):

Sep 01 02:28:33 … 9zwaww04xqfb5qj8jb32gka3id223alc-post-start[17236]: Syncing oauth2 resource servers
Sep 01 02:28:33 … post-start[17236]:     Creating /v1/oauth2/_basic/nextcloud
Sep 01 02:28:33 … post-start[17236]:     Updating /v1/oauth2/nextcloud oauth2_prefer_short_username
Sep 01 02:28:33 … post-start[17236]: Error:
Sep 01 02:28:33 … post-start[17236]:    0: failed to read "/run/secrets/vars/files-oidc-secret/secret"
Sep 01 02:28:33 … post-start[17236]:    1: Permission denied (os error 13)
Sep 01 02:28:33 … post-start[17236]: Location:
Sep 01 02:28:33 … post-start[17236]:    src/client.rs:409

kanidm dies on that control process (gateway-journal.txt:1414-1419):

Sep 01 02:28:33 … systemd[1]: kanidm.service: Control process exited, code=exited, status=1/FAILURE
Sep 01 02:28:33 … systemd[1]: kanidm.service: Failed with result 'exit-code'.
Sep 01 02:28:33 … systemd[1]: Failed to start kanidm identity management daemon.

The named files-idp-client failure in the drive's own error string is downstream — it retries a dead listener for exactly 5 min, twice (gateway-journal.txt:1421, :1590-1618, :1964-1967):

Sep 01 02:28:33 … systemd[1]: Starting Provision the files OAuth2 client on kanidm + share its secret (files off-gateway, ADR 0210)...
Sep 01 02:28:33 … files-idp-client-start[17246]: ERROR kanidm_cli::session: Error during authentication init phase: Transport(… ConnectError("tcp connect error", 127.0.0.1:8443, Os { code: 111, kind: ConnectionRefused, message: "Connection refused" }))
Sep 01 02:33:34 … files-idp-client-start[17242]: kanidm never answered / accepted the files OAuth2 provisioning within the settle budget
Sep 01 02:33:34 … systemd[1]: files-idp-client.service: Main process exited, code=exited, status=1/FAILURE

And the switch itself (gateway-journal.txt at 02:33:35 and 02:38:39):

Sep 01 02:33:35 … nixos[17032]: switching to system configuration /nix/store/1ppk6c85kxa446vgwglfnjc9ps99zjs0-nixos-system-gateway-… failed (status 4)
Sep 01 02:33:35 … systemd[1]: clan-switch-gateway-e30ca538.service: Main process exited, code=exited, status=4/NOPERMISSION

End state on the box (logs/gateway-units.txt), which is exactly the two units and no kanidm listener on 127.0.0.1:8443:

● files-idp-client.service loaded failed failed Provision the files OAuth2 client on kanidm + share its secret (files off-gateway, ADR 0210)
● kanidm.service           loaded failed failed kanidm identity management daemon

A/B control in the same journal. At founding (02:07:43) the identical provisioner ran green because the only client then was gate-oidc, whose var does carry the kanidm read bit (internal/clan/vmguest.go:570-579 — files.secret = { owner = "kanidm"; group = "kanidm"; mode = "0400"; };):

Sep 01 02:07:43 … wfgc3cc8mpzdam8bn33jwhd3mg96l6v5-post-start[3132]:     Updating /v1/oauth2/gate-oidc/_basic_secret

Same binary, same code path, same user — succeeds on the owner-annotated var, Permission denied on files-oidc-secret.

Suspected layer: product (gateway nix rendering)

The defect is a two-line disagreement inside internal/clan/files_idp_gateway.go (the Go renderer that emits machines/<gateway>/files-idp.nix; this is the surface commit 8bb9987d "#1088 — files-idp: impose the shared OAuth2 secret DECLARATIVELY (basicSecretFile)" touched):

  • files_idp_gateway.go:190 — fmt.Fprintf(&b, " basicSecretFile = %s;\n", cfg.SecretVar) hands the path to kanidm, which reads it as the non-root kanidm user (nixpkgs services.kanidm sets User=kanidm, and kanidm-provision runs as ExecStartPost under it).
  • files_idp_gateway.go:158 — renderFilesOIDCSecretGenerator(&b, "") passes an empty owner, so files.go:984 emits files.secret = { }; → clan's default root:root 0400.

The empty owner is deliberate and commented (files_idp_gateway.go:153-157: "kanidm split has no idss-idp bridge, so the file stays root-owned (clan's default) for its root-run consumers") — that reasoning was written for the root-run files-idp-client consumer and was not revisited when basicSecretFile added a second, non-root consumer. files-oidc-secret is now the only kanidm-read var in the repo without owner = "kanidm"; kanidm-tls, kanidm-admins and gate-oidc all declare it.

Not harness, not infra: the harness classified this correctly (it saw through clan's masked success to the exit-4 switch and named the real unit), and the box had 3.4 G RAM free / 63 G disk free with no network fault (logs/gateway-stall.txt).

What plugging it needs

Give the gateway's files-oidc-secret file the kanidm read bit — the same annotation gate-oidc already carries — while keeping the device-side render root-owned (its consumer is root-run occ). Since renderFilesOIDCSecretGenerator currently takes one owner argument shared by both call sites, and share = true shares the secret's value but not its file mode, the two sides need to diverge: the gateway call at files_idp_gateway.go:158 should render files.secret = { owner = "kanidm"; group = "kanidm"; mode = "0400"; };, the device call at files.go:906 should keep its current behaviour. The seam test at internal/clan/files_idp_gateway_test.go:44 already pins the rendered basicSecretFile line and is the natural place to pin the owner line beside it. Re-drive to confirm; a second-order check is that files-idp-client should then finish well inside its 60×5 s budget rather than exhausting it.

Evidence that is absent

  • No live-box section was appended to this brief, so there was no access line and nothing was asked of the running droplet — diagnosis is from harvested logs alone. The gateway journal is complete enough to be decisive (it holds both the failing read and the succeeding control case).
  • There is no logs/droplet-journal.txt under that name; the droplet journals harvested are logs/gateway-journal.txt (671 KB, complete through 02:41) and logs/device-journal.txt.
  • All device-side harvests failed, so nothing corroborates from the joined device: logs/device-units.txt, device-journal.txt, device-caddy.txt all read root@170.64.215.234: Permission denied (publickey,password,keyboard-interactive) with note: device unit-state harvest failed (device unreachable?). This does not affect the diagnosis — the failure is entirely on the gateway.
  • logs/broker-journal.txt is empty by design (off admin mesh, ADR 0208, #681); logs/guest-*.log report the guest was never created (this drive is DO-backed, host.json shows qemu: exit ENOENT); logs/helper.log is 0 bytes.
  • artifacts/journey.json and artifacts/verdict.json both exist and agree with legs.json.

drive 20260901T005009Z red at deploy-takeover: deploy failed (rescue): 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 switch di
evidence: /home/swarm/swarm/Matou/idss/test-results/drive-device/20260901T005009Z on matou-workstation (legs.json and whatever else the drive harvested there) — a representative screenshot is attached here if one was captured

## The failure `deploy-takeover` is the only red leg (26/27 green; `verdict.json` → `"firstRedLeg": "deploy-takeover"`, `skip: 0`). This is **not** the known own-VPS pairing frontier — `pair` is green (157 ms) and `legs.json` carries no skip reasons at all. The takeover deploy adds the `nextcloud` OAuth2 client to kanidm (ADR 0210, files off-gateway). kanidm's `ExecStartPost` provisioner (`kanidm-provision`) creates the client, then dies reading the shared basic secret. That kills `kanidm.service` → `files-idp-client.service` then burns its whole 5-minute settle budget against a dead kanidm → `switch-to-configuration` exits 4 → the drive's masked-exit detector fires. ## Evidence Root cause, `logs/gateway-journal.txt:1354-1404` (repeats identically at `:1733-1757`): ``` Sep 01 02:28:33 … 9zwaww04xqfb5qj8jb32gka3id223alc-post-start[17236]: Syncing oauth2 resource servers Sep 01 02:28:33 … post-start[17236]: Creating /v1/oauth2/_basic/nextcloud Sep 01 02:28:33 … post-start[17236]: Updating /v1/oauth2/nextcloud oauth2_prefer_short_username Sep 01 02:28:33 … post-start[17236]: Error: Sep 01 02:28:33 … post-start[17236]: 0: failed to read "/run/secrets/vars/files-oidc-secret/secret" Sep 01 02:28:33 … post-start[17236]: 1: Permission denied (os error 13) Sep 01 02:28:33 … post-start[17236]: Location: Sep 01 02:28:33 … post-start[17236]: src/client.rs:409 ``` kanidm dies on that control process (`gateway-journal.txt:1414-1419`): ``` Sep 01 02:28:33 … systemd[1]: kanidm.service: Control process exited, code=exited, status=1/FAILURE Sep 01 02:28:33 … systemd[1]: kanidm.service: Failed with result 'exit-code'. Sep 01 02:28:33 … systemd[1]: Failed to start kanidm identity management daemon. ``` The named `files-idp-client` failure in the drive's own error string is downstream — it retries a dead listener for exactly 5 min, twice (`gateway-journal.txt:1421`, `:1590-1618`, `:1964-1967`): ``` Sep 01 02:28:33 … systemd[1]: Starting Provision the files OAuth2 client on kanidm + share its secret (files off-gateway, ADR 0210)... Sep 01 02:28:33 … files-idp-client-start[17246]: ERROR kanidm_cli::session: Error during authentication init phase: Transport(… ConnectError("tcp connect error", 127.0.0.1:8443, Os { code: 111, kind: ConnectionRefused, message: "Connection refused" })) Sep 01 02:33:34 … files-idp-client-start[17242]: kanidm never answered / accepted the files OAuth2 provisioning within the settle budget Sep 01 02:33:34 … systemd[1]: files-idp-client.service: Main process exited, code=exited, status=1/FAILURE ``` And the switch itself (`gateway-journal.txt` at 02:33:35 and 02:38:39): ``` Sep 01 02:33:35 … nixos[17032]: switching to system configuration /nix/store/1ppk6c85kxa446vgwglfnjc9ps99zjs0-nixos-system-gateway-… failed (status 4) Sep 01 02:33:35 … systemd[1]: clan-switch-gateway-e30ca538.service: Main process exited, code=exited, status=4/NOPERMISSION ``` End state on the box (`logs/gateway-units.txt`), which is exactly the two units and no kanidm listener on `127.0.0.1:8443`: ``` ● files-idp-client.service loaded failed failed Provision the files OAuth2 client on kanidm + share its secret (files off-gateway, ADR 0210) ● kanidm.service loaded failed failed kanidm identity management daemon ``` **A/B control in the same journal.** At founding (02:07:43) the identical provisioner ran green because the only client then was `gate-oidc`, whose var *does* carry the kanidm read bit (`internal/clan/vmguest.go:570-579` — `files.secret = { owner = "kanidm"; group = "kanidm"; mode = "0400"; };`): ``` Sep 01 02:07:43 … wfgc3cc8mpzdam8bn33jwhd3mg96l6v5-post-start[3132]: Updating /v1/oauth2/gate-oidc/_basic_secret ``` Same binary, same code path, same user — succeeds on the owner-annotated var, `Permission denied` on `files-oidc-secret`. ## Suspected layer: product (gateway nix rendering) The defect is a two-line disagreement inside `internal/clan/files_idp_gateway.go` (the Go renderer that emits `machines/<gateway>/files-idp.nix`; this is the surface commit `8bb9987d` "#1088 — files-idp: impose the shared OAuth2 secret DECLARATIVELY (basicSecretFile)" touched): - `files_idp_gateway.go:190` — `fmt.Fprintf(&b, " basicSecretFile = %s;\n", cfg.SecretVar)` hands the path to kanidm, which reads it as the **non-root `kanidm` user** (nixpkgs `services.kanidm` sets `User=kanidm`, and `kanidm-provision` runs as `ExecStartPost` under it). - `files_idp_gateway.go:158` — `renderFilesOIDCSecretGenerator(&b, "")` passes an empty owner, so `files.go:984` emits `files.secret = { };` → clan's default **root:root 0400**. The empty owner is deliberate and commented (`files_idp_gateway.go:153-157`: "kanidm split has no idss-idp bridge, so the file stays root-owned (clan's default) for its root-run consumers") — that reasoning was written for the root-run `files-idp-client` consumer and was not revisited when `basicSecretFile` added a second, non-root consumer. `files-oidc-secret` is now the only kanidm-read var in the repo without `owner = "kanidm"`; `kanidm-tls`, `kanidm-admins` and `gate-oidc` all declare it. Not harness, not infra: the harness classified this correctly (it saw through clan's masked success to the exit-4 switch and named the real unit), and the box had 3.4 G RAM free / 63 G disk free with no network fault (`logs/gateway-stall.txt`). ## What plugging it needs Give the gateway's `files-oidc-secret` file the kanidm read bit — the same annotation `gate-oidc` already carries — while keeping the device-side render root-owned (its consumer is root-run `occ`). Since `renderFilesOIDCSecretGenerator` currently takes one owner argument shared by both call sites, and `share = true` shares the secret's *value* but not its file mode, the two sides need to diverge: the gateway call at `files_idp_gateway.go:158` should render `files.secret = { owner = "kanidm"; group = "kanidm"; mode = "0400"; };`, the device call at `files.go:906` should keep its current behaviour. The seam test at `internal/clan/files_idp_gateway_test.go:44` already pins the rendered `basicSecretFile` line and is the natural place to pin the owner line beside it. Re-drive to confirm; a second-order check is that `files-idp-client` should then finish well inside its 60×5 s budget rather than exhausting it. ## Evidence that is absent - **No live-box section was appended to this brief**, so there was no access line and nothing was asked of the running droplet — diagnosis is from harvested logs alone. The gateway journal is complete enough to be decisive (it holds both the failing read and the succeeding control case). - There is **no `logs/droplet-journal.txt`** under that name; the droplet journals harvested are `logs/gateway-journal.txt` (671 KB, complete through 02:41) and `logs/device-journal.txt`. - **All device-side harvests failed**, so nothing corroborates from the joined device: `logs/device-units.txt`, `device-journal.txt`, `device-caddy.txt` all read `root@170.64.215.234: Permission denied (publickey,password,keyboard-interactive)` with `note: device unit-state harvest failed (device unreachable?)`. This does not affect the diagnosis — the failure is entirely on the gateway. - `logs/broker-journal.txt` is empty by design (off admin mesh, ADR 0208, #681); `logs/guest-*.log` report `the guest was never created` (this drive is DO-backed, `host.json` shows `qemu: exit ENOENT`); `logs/helper.log` is 0 bytes. - `artifacts/journey.json` and `artifacts/verdict.json` both exist and agree with `legs.json`. drive `20260901T005009Z` red at `deploy-takeover`: `deploy failed (rescue): 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 switch di` evidence: `/home/swarm/swarm/Matou/idss/test-results/drive-device/20260901T005009Z` on matou-workstation (legs.json and whatever else the drive harvested there) — a representative screenshot is attached here if one was captured <!-- rehearsal-sig: 800a2936720b -->
Owner

Already fixed — closing as a duplicate of #1095, which the watching session filed and landed while this report was being written.

The diagnosis here matches exactly (kanidm-provision runs as kanidm.service's post-start as the non-root kanidm user; the shared files-oidc-secret var was clan-default root:root 0400; the post-start's failure fails kanidm itself, and the named files-idp-client failure is downstream against a dead listener). Thank you for the far better evidence trail — gateway-journal.txt:1354-1404 and the status=4/NOPERMISSION switch line are the clean citations; the session read it live off the surviving droplet before the artifacts finished gathering.

Fixed in 9d414e84 — renderFilesOIDCSecretGenerator(&b, "kanidm") on the gateway side of the split, the gate client's long-standing shape for the identical reader (gate-oidc, internal/clan/vmguest.go:570-575: "kanidm reads it as the non-root kanidm user (basicSecretFile)"). Ownership stays per-machine — share = true shares the VALUE, not the file mode — so the device keeps root (member device) or idss-idp (co-hosted), where no kanidm user exists and a kanidm owner would fail the chown (the mirror of #1029). Red-before-green pinned in internal/clan/files_idp_gateway_test.go; full internal/clan suite green.

No action needed on this ticket. #854's next cycle syncs 9d414e84 and drives with the fix aboard.

(Ruled by the session under ADR 0174 — a two-way-door render change with an in-repo precedent. It was fixed directly rather than routed to the swarm because the executor was already re-firing and each cycle pays a ~50–60 minute gateway-image rebuild — measured — before it would have re-hit this same line. That rebuild cost is now its own ticket, #1096.)

Already fixed — closing as a duplicate of #1095, which the watching session filed and landed while this report was being written. The diagnosis here matches exactly (kanidm-provision runs as kanidm.service's post-start as the non-root `kanidm` user; the shared `files-oidc-secret` var was clan-default root:root 0400; the post-start's failure fails kanidm itself, and the named `files-idp-client` failure is downstream against a dead listener). Thank you for the far better evidence trail — `gateway-journal.txt:1354-1404` and the `status=4/NOPERMISSION` switch line are the clean citations; the session read it live off the surviving droplet before the artifacts finished gathering. **Fixed in `9d414e84`** — `renderFilesOIDCSecretGenerator(&b, "kanidm")` on the gateway side of the split, the gate client's long-standing shape for the identical reader (`gate-oidc`, `internal/clan/vmguest.go:570-575`: *"kanidm reads it as the non-root kanidm user (basicSecretFile)"*). Ownership stays per-machine — `share = true` shares the VALUE, not the file mode — so the device keeps root (member device) or idss-idp (co-hosted), where no kanidm user exists and a kanidm owner would fail the chown (the mirror of #1029). Red-before-green pinned in `internal/clan/files_idp_gateway_test.go`; full `internal/clan` suite green. No action needed on this ticket. #854's next cycle syncs `9d414e84` and drives with the fix aboard. (Ruled by the session under ADR 0174 — a two-way-door render change with an in-repo precedent. It was fixed directly rather than routed to the swarm because the executor was already re-firing and each cycle pays a ~50–60 minute gateway-image rebuild — measured — before it would have re-hit this same line. That rebuild cost is now its own ticket, #1096.)
ben closed this issue 2026-09-01 02:59:14 +00:00
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#1097
No description provided.