member-suspend 401: files deploy renders the Nextcloud admin export, but the switch-exempt control plane never restarts to inherit it #863

Closed
opened 2026-08-26 01:02:38 +00:00 by ben · 2 comments
Owner

Failure

Droplet drive 20260825T230453Z reds 24/26-green at invite-member: POST /api/v1/members/e2e-member/suspend → 400 act_failed: nextcloud: GET /ocs/v1.php/cloud/users/e2e-member: unauthorised (HTTP 401) — check the admin credential. First drive ever to reach this leg live (it rode in with #789's arc) — a latent wire, not a regression. #858's fix HELD: deploy-files greened and the control plane survived its own switch for the first time.

Root cause (proven live on the kept box, root@209.38.82.73)

The Nextcloud reconciler port gets its admin credential from process env at boot (control-plane/cmd/control-plane/main.go productionServicePorts: IDSS_NEXTCLOUD_ADMIN_USER/_PASSWORD → nextcloud.New). That env is exported by the unit's start script, and the export only appears when the files co-host deploy re-renders the surface (EnableGatewayNextcloudExport, #790) — i.e. after the control plane booted.

Before #858, the switch restarted the unit and the new process inherited the export (while dying of the cgroup kill — the #858 bug). With #858's restartIfChanged = false; stopIfChanged = false, the switch now (correctly) leaves the unit alone — and nothing else ever restarts it, so the running process keeps its pre-Nextcloud environment and the port authenticates as ("","") → 401.

Live proof on the kept box:

  • systemctl is-active idss-control-plane → active, ActiveEnterTimestamp 23:12:15 (boot, pre-attach)
  • /proc/<MainPID>/environ → zero NEXTCLOUD vars
  • current ExecStart script /nix/store/qvhgw…-idss-control-plane-start → 2 IDSS_NEXTCLOUD_ADMIN export lines

A manual systemctl restart idss-control-plane would discharge it — which is the diagnosis, not the fix.

Fix shape (suggested, not binding)

Boot-time env is the wrong lifetime for a credential minted mid-life by the process's own deploy. Prefer lazy per-call resolution: render the password as a path (IDSS_NEXTCLOUD_ADMIN_PASSWORD_FILE → the materialised clan-var file the start script currently cats) and have the nextcloud port read it per call (empty/absent file → today's honest act_failed). Same trap exists for every productionServicePorts sibling (mail/static-sites/code/…) whose service co-hosts after boot — fix the pattern, or at minimum the Nextcloud instance plus a GOTCHAS entry naming the invariant: a unit exempted from switch restarts must not carry boot-frozen credentials for services deployed after its boot. Self-restart shapes trade this 401 for #861's mid-deploy 404 — see #858's close-report.

Related: #858 (the exemption), #861 (persist the run store, then detach), #789 (whose live proof — invite→FirstLogin→suspend — still rides the next green drive).

## Failure Droplet drive `20260825T230453Z` reds 24/26-green at `invite-member`: `POST /api/v1/members/e2e-member/suspend` → 400 `act_failed`: `nextcloud: GET /ocs/v1.php/cloud/users/e2e-member: unauthorised (HTTP 401) — check the admin credential`. First drive ever to reach this leg live (it rode in with #789's arc) — a latent wire, not a regression. **#858's fix HELD**: `deploy-files` greened and the control plane survived its own switch for the first time. ## Root cause (proven live on the kept box, `root@209.38.82.73`) The Nextcloud reconciler port gets its admin credential from process env at **boot** (`control-plane/cmd/control-plane/main.go` `productionServicePorts`: `IDSS_NEXTCLOUD_ADMIN_USER/_PASSWORD` → `nextcloud.New`). That env is exported by the unit's start script, and the export only appears when the files co-host deploy re-renders the surface (`EnableGatewayNextcloudExport`, #790) — i.e. **after** the control plane booted. Before #858, the switch restarted the unit and the new process inherited the export (while dying of the cgroup kill — the #858 bug). With #858's `restartIfChanged = false; stopIfChanged = false`, the switch now (correctly) leaves the unit alone — **and nothing else ever restarts it**, so the running process keeps its pre-Nextcloud environment and the port authenticates as `("","")` → 401. Live proof on the kept box: - `systemctl is-active idss-control-plane` → `active`, `ActiveEnterTimestamp` 23:12:15 (boot, pre-attach) - `/proc/<MainPID>/environ` → **zero** `NEXTCLOUD` vars - current `ExecStart` script `/nix/store/qvhgw…-idss-control-plane-start` → **2** `IDSS_NEXTCLOUD_ADMIN` export lines A manual `systemctl restart idss-control-plane` would discharge it — which is the diagnosis, not the fix. ## Fix shape (suggested, not binding) Boot-time env is the wrong lifetime for a credential minted mid-life by the process's own deploy. Prefer **lazy per-call resolution**: render the password as a *path* (`IDSS_NEXTCLOUD_ADMIN_PASSWORD_FILE` → the materialised clan-var file the start script currently `cat`s) and have the nextcloud port read it per call (empty/absent file → today's honest `act_failed`). Same trap exists for every `productionServicePorts` sibling (mail/static-sites/code/…) whose service co-hosts after boot — fix the pattern, or at minimum the Nextcloud instance plus a GOTCHAS entry naming the invariant: **a unit exempted from switch restarts must not carry boot-frozen credentials for services deployed after its boot.** Self-restart shapes trade this 401 for #861's mid-deploy 404 — see #858's close-report. Related: #858 (the exemption), #861 (persist the run store, then detach), #789 (whose live proof — invite→FirstLogin→suspend — still rides the next green drive).

swarm-claim host=elitebook-distributed-server-03 run=10103
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=elitebook-distributed-server-03 run=10103 (automated multi-host claim — lowest live claim id works this ticket)

close-report for #863 — status success

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

envelope
{
  "issue": 863,
  "status": "success",
  "commits": [
    "b3506a360694e32d98777216cb37db57480dd4bf"
  ],
  "changed_files": [
    "STATUS.md",
    "control-plane/cmd/control-plane/main.go",
    "control-plane/cmd/control-plane/offboard_catalogue_test.go",
    "docs/GOTCHAS.md",
    "internal/clan/clan.go",
    "internal/clan/files.go",
    "internal/clan/files_attach.go",
    "internal/clan/vmguest.go",
    "internal/nextcloud/nextcloud.go",
    "internal/nextcloud/nextcloud_test.go"
  ],
  "tests": [
    {
      "command": "go build ./...",
      "exit_code": 0
    },
    {
      "command": "go vet ./...",
      "exit_code": 0
    },
    {
      "command": "go test ./internal/nextcloud/... ./internal/clan/... ./control-plane/...",
      "exit_code": 0
    },
    {
      "command": "gofmt -l (changed files)",
      "exit_code": 0
    }
  ],
  "criteria": {
    "The reconciler no longer 401s from a boot-frozen credential: the Nextcloud port resolves its admin app password per call from a boot-known file path, so a secret materialised mid-life by the files co-host deploy is honoured without a control-plane restart": "internal/nextcloud/nextcloud.go (NewWithSecretResolver + SecretFromFile, per-call p.secret()); proven by internal/nextcloud/nextcloud_test.go TestSecretResolver_PicksUpMidLifeMaterialisedSecret (writes the secret file AFTER the port is built, same port then authenticates)",
    "An absent/empty credential file is the honest act_failed, never a fabricated success (ADR 0100)": "SecretFromFile returns \"\" on absent/empty/unreadable file -> HTTP 401 -> the existing unauthorised error; TestSecretFromFile_ResolvesPerCall + TestUnauthorized_IsAnError",
    "The credential is resolvable at BOOT without the post-boot files export: user falls back to the ocadmin constant and the path to clan.NextcloudAdminPassPath": "control-plane/cmd/control-plane/main.go productionServicePorts; internal/clan/files_attach.go NextcloudAdminPassPath",
    "The gateway export renders a PATH not a boot-frozen $(cat) value, and #790's gated export + eval assertion stay green": "internal/clan/vmguest.go IDSS_NEXTCLOUD_ADMIN_PASSWORD_FILE=${...adminpass.path}; internal/clan tests green (TestEnableGatewayNextcloudExport_FullInstall/_VMPath)",
    "The invariant is recorded for the sibling ports that share the trap": "docs/GOTCHAS.md #87 (a switch-exempt unit must not carry boot-frozen credentials for services deployed after its boot; flags mail/static-sites/code/chat)"
  },
  "summary": "The switch-exempt control plane's Nextcloud admin credential is now resolved per call from a boot-known file path instead of frozen in boot env, so a mid-life-materialised secret is honoured with no restart and the member-suspend 401 is closed.",
  "blockers": []
}
**close-report** for #863 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 863, "status": "success", "commits": [ "b3506a360694e32d98777216cb37db57480dd4bf" ], "changed_files": [ "STATUS.md", "control-plane/cmd/control-plane/main.go", "control-plane/cmd/control-plane/offboard_catalogue_test.go", "docs/GOTCHAS.md", "internal/clan/clan.go", "internal/clan/files.go", "internal/clan/files_attach.go", "internal/clan/vmguest.go", "internal/nextcloud/nextcloud.go", "internal/nextcloud/nextcloud_test.go" ], "tests": [ { "command": "go build ./...", "exit_code": 0 }, { "command": "go vet ./...", "exit_code": 0 }, { "command": "go test ./internal/nextcloud/... ./internal/clan/... ./control-plane/...", "exit_code": 0 }, { "command": "gofmt -l (changed files)", "exit_code": 0 } ], "criteria": { "The reconciler no longer 401s from a boot-frozen credential: the Nextcloud port resolves its admin app password per call from a boot-known file path, so a secret materialised mid-life by the files co-host deploy is honoured without a control-plane restart": "internal/nextcloud/nextcloud.go (NewWithSecretResolver + SecretFromFile, per-call p.secret()); proven by internal/nextcloud/nextcloud_test.go TestSecretResolver_PicksUpMidLifeMaterialisedSecret (writes the secret file AFTER the port is built, same port then authenticates)", "An absent/empty credential file is the honest act_failed, never a fabricated success (ADR 0100)": "SecretFromFile returns \"\" on absent/empty/unreadable file -> HTTP 401 -> the existing unauthorised error; TestSecretFromFile_ResolvesPerCall + TestUnauthorized_IsAnError", "The credential is resolvable at BOOT without the post-boot files export: user falls back to the ocadmin constant and the path to clan.NextcloudAdminPassPath": "control-plane/cmd/control-plane/main.go productionServicePorts; internal/clan/files_attach.go NextcloudAdminPassPath", "The gateway export renders a PATH not a boot-frozen $(cat) value, and #790's gated export + eval assertion stay green": "internal/clan/vmguest.go IDSS_NEXTCLOUD_ADMIN_PASSWORD_FILE=${...adminpass.path}; internal/clan tests green (TestEnableGatewayNextcloudExport_FullInstall/_VMPath)", "The invariant is recorded for the sibling ports that share the trap": "docs/GOTCHAS.md #87 (a switch-exempt unit must not carry boot-frozen credentials for services deployed after its boot; flags mail/static-sites/code/chat)" }, "summary": "The switch-exempt control plane's Nextcloud admin credential is now resolved per call from a boot-known file path instead of frozen in boot env, so a mid-life-materialised secret is honoured with no restart and the member-suspend 401 is closed.", "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#863
No description provided.