the control plane runs the PRE-files env until its next start — #858's switch exemption defers the #790 Nextcloud export, and the in-memory deploy run store blocks the explicit restart that would close it #861

Closed
opened 2026-08-25 22:44:35 +00:00 by matou-build-agent · 1 comment

Follow-up from #858 (filed by the session that fixed it — the residue that fix deliberately leaves open).

What #858 changed

gatewayControlPlaneUnit (internal/clan/vmguest.go) now renders restartIfChanged = false + stopIfChanged = false on systemd.services.idss-control-plane, so a gateway switch never stops the very unit whose cgroup holds the clan CLI driving it. That is what stops the switch dying at 101 mid-stop-phase and leaving the control plane down forever.

The residue

Because the switch no longer restarts it, a re-render that changes the unit's ENV takes effect only on the unit's next start. The live case is #790's EnableGatewayNextcloudExport: after deploy-files, the unit text carries IDSS_NEXTCLOUD_ADMIN_USER / IDSS_NEXTCLOUD_ADMIN_PASSWORD, but the RUNNING control plane still has the pre-files environment — so the member-orbit reconciler (internal/nextcloud, ADR 0062 part 2) has no OCS credential until something restarts the unit.

This is strictly better than the fault it replaces (the control plane was previously dead, not stale), but it is not closed.

Why the obvious fix does not work yet

The natural close is "issue an explicit restart once the deploy returns". It cannot land as-is:

deployRunStore (internal/controlapi/provision.go:~165) is in-memory — its own comment says "the run and the store share the control-plane process, so a restart loses both together". A restart therefore makes GET /api/v1/provision/devices/{id}/deploy answer 404 no_deploy, and the dashboard's poll treats a definitive 4xx as terminal at once (GOTCHAS #84's rule, dashboard/src/lib/api/provisionClient.ts). The #835 restartToleranceMs (90s) rides out 5xx/refused, NOT a 404. So an explicit restart mid- or just-post-deploy trades a 502 red for a 404 red.

The same fact is why #858 did not take the other shape on the table (detach the driver into its own transient systemd-run unit and let the switch freely restart the control plane): that shape restarts the control plane during the deploy, which loses the live run entirely.

What closing it needs

  1. Persist the deploy run store to IDSS_STATE_DIR (/var/lib/idss) and re-adopt the latest frame per device on start, so a control-plane restart is a poll gap (5xx/refused, already tolerated) rather than a 404.
  2. Then issue the explicit idss-control-plane restart after the deploy's terminal frame is written — detached (systemd-run / systemctl restart --no-block) so the restarting process is not the one issuing it.
  3. With (1) landed, the detached-driver shape becomes available too, and is the stronger invariant long-term (the switch may then restart the control plane freely). Worth reconsidering at that point rather than now.

Verification

Unit-testable at the seam for (1) — write frames, restart, read back. The end-to-end proof is a droplet drive reaching deploy-files green with the reconciler holding a live Nextcloud credential.

Follow-up from #858 (filed by the session that fixed it — the residue that fix deliberately leaves open). ## What #858 changed `gatewayControlPlaneUnit` (`internal/clan/vmguest.go`) now renders `restartIfChanged = false` + `stopIfChanged = false` on `systemd.services.idss-control-plane`, so a gateway switch never stops the very unit whose cgroup holds the `clan` CLI driving it. That is what stops the switch dying at 101 mid-stop-phase and leaving the control plane down forever. ## The residue Because the switch no longer restarts it, **a re-render that changes the unit's ENV takes effect only on the unit's next start.** The live case is #790's `EnableGatewayNextcloudExport`: after `deploy-files`, the unit *text* carries `IDSS_NEXTCLOUD_ADMIN_USER` / `IDSS_NEXTCLOUD_ADMIN_PASSWORD`, but the RUNNING control plane still has the pre-files environment — so the member-orbit reconciler (`internal/nextcloud`, ADR 0062 part 2) has no OCS credential until something restarts the unit. This is strictly better than the fault it replaces (the control plane was previously dead, not stale), but it is not closed. ## Why the obvious fix does not work yet The natural close is "issue an explicit restart once the deploy returns". It cannot land as-is: `deployRunStore` (`internal/controlapi/provision.go:~165`) is **in-memory** — its own comment says "the run and the store share the control-plane process, so a restart loses both together". A restart therefore makes `GET /api/v1/provision/devices/{id}/deploy` answer **404 `no_deploy`**, and the dashboard's poll treats a definitive 4xx as terminal at once (GOTCHAS #84's rule, `dashboard/src/lib/api/provisionClient.ts`). The #835 `restartToleranceMs` (90s) rides out 5xx/refused, NOT a 404. So an explicit restart mid- or just-post-deploy trades a 502 red for a 404 red. The same fact is why #858 did **not** take the other shape on the table (detach the driver into its own transient `systemd-run` unit and let the switch freely restart the control plane): that shape restarts the control plane *during* the deploy, which loses the live run entirely. ## What closing it needs 1. **Persist the deploy run store** to `IDSS_STATE_DIR` (`/var/lib/idss`) and re-adopt the latest frame per device on start, so a control-plane restart is a poll gap (5xx/refused, already tolerated) rather than a 404. 2. Then issue the explicit `idss-control-plane` restart after the deploy's terminal frame is written — detached (`systemd-run` / `systemctl restart --no-block`) so the restarting process is not the one issuing it. 3. With (1) landed, the **detached-driver** shape becomes available too, and is the stronger invariant long-term (the switch may then restart the control plane freely). Worth reconsidering at that point rather than now. ## Verification Unit-testable at the seam for (1) — write frames, restart, read back. The end-to-end proof is a droplet drive reaching `deploy-files` green with the reconciler holding a live Nextcloud credential.
Author
Member

This was generated by AI during triage.

Ruled by agent under ADR 0174 — veto anytime

Ruling: wontfix — already addressed, by a different (and since-preferred) mechanism than the one this issue's closing plan proposes.

What changed since filing: #863 closed the concrete case this issue named (the #790 Nextcloud OCS credential) by making the control plane resolve that credential lazily, per call, from a boot-known file path, instead of taking it from process env at boot. That removes the need for any restart to pick up a post-deploy-files render change for this credential — the specific residue this issue asks to close.

Why the proposed direction is superseded, not just the symptom: this issue's own closing plan — persist deployRunStore, then issue an explicit restart once a deploy's terminal frame lands — is the shape #863's own documentation explicitly rules out for this class of problem: "Self-restart shapes only trade this 401 for entry #84's 404 no_deploy (the #861 residue) — they are not the way out." The chosen path forward for the remaining boot-frozen ports (mail/static-sites/code/chat) is the same per-call lazy-resolver pattern #863 used, applied per-service as a live drive reaches each one — not the persisted-run-store/restart architecture this issue asks for.

Why this is a two-way door: closing is reversible (reopen if a genuinely new case needs the persisted-run-store direction specifically); provable by the landed commit and its passing test proving the lazy resolver picks up a mid-life credential with no restart at all.

What proves it: the fix that resolved #790's residue via a per-call secret resolver reading a boot-known path (nextcloud.SecretFromFile / NewWithSecretResolver), its test proving the same port authenticates after the secret materializes mid-life with zero restarts, and GOTCHAS #86/#87's own text naming the restart direction as rejected for this problem class.

If a future feature needs the control plane to pick up a post-boot render change that can't be expressed as a lazily-read file (unlike a credential), that would be a new, narrower ticket against that specific service — not a reopening of this one's general run-store-persistence proposal.

> *This was generated by AI during triage.* Ruled by agent under ADR 0174 — veto anytime **Ruling:** `wontfix` — already addressed, by a different (and since-preferred) mechanism than the one this issue's closing plan proposes. **What changed since filing:** #863 closed the concrete case this issue named (the #790 Nextcloud OCS credential) by making the control plane resolve that credential lazily, per call, from a boot-known file path, instead of taking it from process env at boot. That removes the need for any restart to pick up a post-`deploy-files` render change for this credential — the specific residue this issue asks to close. **Why the proposed direction is superseded, not just the symptom:** this issue's own closing plan — persist `deployRunStore`, then issue an explicit restart once a deploy's terminal frame lands — is the shape #863's own documentation explicitly rules out for this class of problem: "Self-restart shapes only trade this 401 for entry #84's 404 no_deploy (the #861 residue) — they are not the way out." The chosen path forward for the remaining boot-frozen ports (mail/static-sites/code/chat) is the same per-call lazy-resolver pattern #863 used, applied per-service as a live drive reaches each one — not the persisted-run-store/restart architecture this issue asks for. **Why this is a two-way door:** closing is reversible (reopen if a genuinely new case needs the persisted-run-store direction specifically); provable by the landed commit and its passing test proving the lazy resolver picks up a mid-life credential with no restart at all. **What proves it:** the fix that resolved #790's residue via a per-call secret resolver reading a boot-known path (`nextcloud.SecretFromFile` / `NewWithSecretResolver`), its test proving the same port authenticates after the secret materializes mid-life with zero restarts, and GOTCHAS #86/#87's own text naming the restart direction as rejected for this problem class. If a future feature needs the control plane to pick up a post-boot render change that can't be expressed as a lazily-read file (unlike a credential), that would be a new, narrower ticket against that specific service — not a reopening of this one's general run-store-persistence proposal.
matou-build-agent 2026-08-26 02:44:37 +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.

Dependencies

No dependencies set.

Reference
Matou/idss#861
No description provided.