provision: an interrupted deploy run is not persisted or resumed on control-plane restart (only fail-loud landed in #1348) #1350

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

Split out of #1348. That ticket landed the ADR 0027 BLACK-BOX fix only: pollToCompletion now fails loud when a run it watched running 404s after a control-plane restart (GOTCHAS #208). It did NOT make the run survivable.

The provisioning deploy run lives only in an in-memory deployRunStore (internal/controlapi/provision.go), the worker is a detached context.Background() goroutine, and there is no persistence, no startup reconcile that marks an interrupted run failed, and no heartbeat/timeout. Contrast the FOUNDING flow (internal/founding/store.go FileStore + privatepath.go lazy resume), which persists to disk and resumes an interrupted StandupDeploying.

Decide + build: should a provisioning deploy PERSIST its run and RESUME after a restart (the founding pattern), or is fail-loud + operator re-confirm the intended contract? Whichever, close the gap that a restart mid-deploy loses the run. A server-side persisted store also lets the poll endpoint distinguish never-deployed (404) from lost-run (a real failure) at the source, rather than only client-side.

Split out of #1348. That ticket landed the ADR 0027 BLACK-BOX fix only: `pollToCompletion` now fails loud when a run it watched running 404s after a control-plane restart (GOTCHAS #208). It did NOT make the run survivable. The provisioning deploy run lives only in an in-memory `deployRunStore` (`internal/controlapi/provision.go`), the worker is a detached `context.Background()` goroutine, and there is no persistence, no startup reconcile that marks an interrupted run failed, and no heartbeat/timeout. Contrast the FOUNDING flow (`internal/founding/store.go` FileStore + `privatepath.go` lazy resume), which persists to disk and resumes an interrupted `StandupDeploying`. Decide + build: should a provisioning deploy PERSIST its run and RESUME after a restart (the founding pattern), or is fail-loud + operator re-confirm the intended contract? Whichever, close the gap that a restart mid-deploy loses the run. A server-side persisted store also lets the poll endpoint distinguish never-deployed (404) from lost-run (a real failure) at the source, rather than only client-side.
Author
Member

This was generated by AI during triage.

Ruled by agent under ADR 0174 — veto anytime

The decision this ticket poses — should a provisioning deploy PERSIST its run and RESUME after a control-plane restart (the founding pattern), or is fail-loud + operator re-confirm the intended contract?

Ruling: PERSIST + RESUME, mirroring the founding flow. The provisioning deploy run should be persisted to a disk-backed store and reconciled/resumed on control-plane startup, following the internal/founding FileStore + lazy-resume precedent — not left as fail-loud only.

Why this ruling:

  • It fully closes the gap the ticket names (a restart mid-deploy loses the run); fail-loud alone leaves the run unrecoverable.
  • There is an in-repo, already-proven precedent to mirror: internal/founding persists to disk (FileStore) and resumes an interrupted StandupDeploying via lazy resume (privatepath.go). Adopting the same shape keeps the two deploy flows consistent rather than divergent.
  • It delivers the server-side benefit the ticket itself flags: a persisted store lets the poll endpoint distinguish never-deployed (404) from lost-run (a real failure) at the source, rather than only client-side (which is all #1348's fail-loud gave).

Why this is a two-way door: the contract is revertible by a later commit (the store and the reconcile step can be removed or swapped for a different contract), it is provable by a restart-resume test, and it is not on the one-way-door list — no personal credentials, no security-posture widening, no member-facing trust accept, no data destruction, no non-routine spend. Ben's veto is asynchronous; a veto reverts to the fail-loud + re-confirm contract.

What proves it: the acceptance criteria below — specifically a test that starts a deploy, simulates a control-plane restart mid-run, and asserts the run is either resumed to completion or reconciled to a terminal failed state (never silently lost), plus a poll-endpoint test distinguishing never-deployed from lost-run.


Agent Brief

Category: enhancement
Summary: Make an interrupted provisioning deploy run survivable — persist it to a disk-backed store and reconcile/resume on control-plane restart, mirroring the founding FileStore + lazy-resume pattern.

Current behavior:
A provisioning deploy run lives only in an in-memory store keyed per device (deployRunStore in the control API), the worker runs in a detached context.Background() goroutine, and there is no persistence, no startup reconcile, and no heartbeat/timeout. If the control plane restarts mid-deploy the run is lost with no record. #1348 landed only the ADR 0027 black-box fix: the poll now fails loud client-side when a run it watched running 404s after a restart (GOTCHAS #208). It did NOT make the run survivable.

By contrast the FOUNDING flow persists its run to disk (internal/founding FileStore) and lazily resumes an interrupted StandupDeploying (internal/founding/privatepath.go).

Desired behavior:
A provisioning deploy run is persisted to a disk-backed store as it progresses. On control-plane startup, a reconcile step inspects persisted runs and either resumes an interrupted run to completion or marks it terminally failed — never leaves it silently lost or wedged "running" forever. The poll endpoint reads the persisted store so it can distinguish never-deployed (no run record → 404) from lost-run (a persisted run that was interrupted → a real, reported failure) at the source.

Key interfaces:

  • The provisioning deploy-run store (currently the in-memory deployRunStore) — should gain a disk-backed persistence layer modelled on the founding FileStore (persist each DeployRun frame / terminal state; survive process restart).
  • A startup reconcile hook — on control-plane boot, walk persisted runs and resolve any left mid-flight (resume via the founding lazy-resume pattern, or mark failed with a clear terminal reason).
  • The deploy-run poll endpoint — should consult the persisted store so never-deployed vs lost-run is distinguishable server-side, rather than only via the client-side fail-loud from #1348.
  • The detached deploy worker — should record enough state (and ideally a heartbeat/timeout) that a reconcile can tell "still progressing" from "abandoned".

Acceptance criteria:

  • A provisioning deploy run is persisted to disk as it progresses (verified by reading the store back after the run advances).
  • A test that starts a deploy, simulates a control-plane restart mid-run, and asserts the run is resumed to completion OR reconciled to a terminal failed state — never silently lost and never stuck reporting "running" indefinitely.
  • The poll endpoint distinguishes never-deployed (404 / no record) from lost-run (a persisted, interrupted run surfaced as a failure) server-side.
  • The founding flow's persistence/resume behavior is unchanged (the new store follows its pattern; it does not modify it).

Out of scope:

  • The two DetachService removal-mirror gaps (#1349).
  • The brand-reach drive guest-side assertion (#1351).
  • Reworking the founding flow itself — reuse its pattern, don't refactor it.
  • Any change to the ADR 0027 black-box fail-loud poll behavior beyond letting it read the new persisted store.
> *This was generated by AI during triage.* **Ruled by agent under ADR 0174 — veto anytime** **The decision this ticket poses** — should a provisioning deploy PERSIST its run and RESUME after a control-plane restart (the founding pattern), or is fail-loud + operator re-confirm the intended contract? **Ruling: PERSIST + RESUME, mirroring the founding flow.** The provisioning deploy run should be persisted to a disk-backed store and reconciled/resumed on control-plane startup, following the `internal/founding` FileStore + lazy-resume precedent — not left as fail-loud only. **Why this ruling:** - It fully closes the gap the ticket names (a restart mid-deploy loses the run); fail-loud alone leaves the run unrecoverable. - There is an in-repo, already-proven precedent to mirror: `internal/founding` persists to disk (`FileStore`) and resumes an interrupted `StandupDeploying` via lazy resume (`privatepath.go`). Adopting the same shape keeps the two deploy flows consistent rather than divergent. - It delivers the server-side benefit the ticket itself flags: a persisted store lets the poll endpoint distinguish never-deployed (404) from lost-run (a real failure) **at the source**, rather than only client-side (which is all #1348's fail-loud gave). **Why this is a two-way door:** the contract is revertible by a later commit (the store and the reconcile step can be removed or swapped for a different contract), it is provable by a restart-resume test, and it is not on the one-way-door list — no personal credentials, no security-posture widening, no member-facing trust accept, no data destruction, no non-routine spend. Ben's veto is asynchronous; a veto reverts to the fail-loud + re-confirm contract. **What proves it:** the acceptance criteria below — specifically a test that starts a deploy, simulates a control-plane restart mid-run, and asserts the run is either resumed to completion or reconciled to a terminal failed state (never silently lost), plus a poll-endpoint test distinguishing never-deployed from lost-run. --- ## Agent Brief **Category:** enhancement **Summary:** Make an interrupted provisioning deploy run survivable — persist it to a disk-backed store and reconcile/resume on control-plane restart, mirroring the founding FileStore + lazy-resume pattern. **Current behavior:** A provisioning deploy run lives only in an in-memory store keyed per device (`deployRunStore` in the control API), the worker runs in a detached `context.Background()` goroutine, and there is no persistence, no startup reconcile, and no heartbeat/timeout. If the control plane restarts mid-deploy the run is lost with no record. #1348 landed only the ADR 0027 black-box fix: the poll now fails loud client-side when a run it watched running 404s after a restart (GOTCHAS #208). It did NOT make the run survivable. By contrast the FOUNDING flow persists its run to disk (`internal/founding` `FileStore`) and lazily resumes an interrupted `StandupDeploying` (`internal/founding/privatepath.go`). **Desired behavior:** A provisioning deploy run is persisted to a disk-backed store as it progresses. On control-plane startup, a reconcile step inspects persisted runs and either resumes an interrupted run to completion or marks it terminally failed — never leaves it silently lost or wedged "running" forever. The poll endpoint reads the persisted store so it can distinguish **never-deployed** (no run record → 404) from **lost-run** (a persisted run that was interrupted → a real, reported failure) at the source. **Key interfaces:** - The provisioning deploy-run store (currently the in-memory `deployRunStore`) — should gain a disk-backed persistence layer modelled on the founding `FileStore` (persist each `DeployRun` frame / terminal state; survive process restart). - A startup reconcile hook — on control-plane boot, walk persisted runs and resolve any left mid-flight (resume via the founding lazy-resume pattern, or mark failed with a clear terminal reason). - The deploy-run poll endpoint — should consult the persisted store so `never-deployed` vs `lost-run` is distinguishable server-side, rather than only via the client-side fail-loud from #1348. - The detached deploy worker — should record enough state (and ideally a heartbeat/timeout) that a reconcile can tell "still progressing" from "abandoned". **Acceptance criteria:** - [ ] A provisioning deploy run is persisted to disk as it progresses (verified by reading the store back after the run advances). - [ ] A test that starts a deploy, simulates a control-plane restart mid-run, and asserts the run is resumed to completion OR reconciled to a terminal failed state — never silently lost and never stuck reporting "running" indefinitely. - [ ] The poll endpoint distinguishes never-deployed (404 / no record) from lost-run (a persisted, interrupted run surfaced as a failure) server-side. - [ ] The founding flow's persistence/resume behavior is unchanged (the new store follows its pattern; it does not modify it). **Out of scope:** - The two DetachService removal-mirror gaps (#1349). - The brand-reach drive guest-side assertion (#1351). - Reworking the founding flow itself — reuse its pattern, don't refactor it. - Any change to the ADR 0027 black-box fail-loud poll behavior beyond letting it read the new persisted store.
Author
Member

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

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

close-report for #1350 — status success

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

envelope
{
  "issue": 1350,
  "status": "success",
  "commits": [
    "f76b01bf"
  ],
  "changed_files": [
    "internal/controlapi/deployrunstore.go",
    "internal/controlapi/deployrunstore_test.go",
    "internal/controlapi/provision.go",
    "control-plane/cmd/control-plane/main.go",
    "docs/GOTCHAS.md",
    "STATUS.md"
  ],
  "tests": [
    {
      "command": "go test ./internal/controlapi/...",
      "exit_code": 0
    },
    {
      "command": "go test ./control-plane/cmd/control-plane/",
      "exit_code": 0
    },
    {
      "command": "go build ./...",
      "exit_code": 0
    }
  ],
  "criteria": {
    "A provisioning deploy run is persisted to disk as it progresses (verified by reading the store back after the run advances)": "deployrunstore.go put() persists each frame via jsonstore.File atomically; proven by TestDeployRunStore_PersistsAcrossReopen (a frame put to one store is read back by a fresh store over the same path)",
    "A test that starts a deploy, simulates a control-plane restart mid-run, and asserts the run is resumed to completion OR reconciled to a terminal failed state — never silently lost and never stuck reporting running indefinitely": "TestDeployRunStore_ReconcilesInterruptedRunToFailed: a non-terminal frame persisted, then a fresh store (restart) reconciles it to a terminal clean-retry Failure (not lost, not still-running), and it survives a second restart; TestDeployRunStore_SettledRunSurvivesReconcile confirms a settled run is untouched",
    "The poll endpoint distinguishes never-deployed (404 / no record) from lost-run (a persisted, interrupted run surfaced as a failure) server-side": "TestProvisionDeploy_PollDistinguishesLostRunFrom404AfterRestart: over an HTTP handler reconstructed on the same store path, GET .../totara/deploy returns 200 + Failure (lost-run) while GET .../rimu/deploy returns 404 (never-deployed)",
    "The founding flow's persistence/resume behavior is unchanged (the new store follows its pattern; it does not modify it)": "No file under internal/founding changed (git diff touches only controlapi, control-plane main, docs, STATUS); the new store reuses internal/jsonstore, the same shared single-writer backing founding uses"
  },
  "summary": "Persisted the provisioning deploy run to a disk-backed store that reconciles an interrupted run to a terminal failure on control-plane restart, so the poll endpoint distinguishes never-deployed (404) from lost-run (failure) at the source.",
  "blockers": []
}
**close-report** for #1350 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 1350, "status": "success", "commits": [ "f76b01bf" ], "changed_files": [ "internal/controlapi/deployrunstore.go", "internal/controlapi/deployrunstore_test.go", "internal/controlapi/provision.go", "control-plane/cmd/control-plane/main.go", "docs/GOTCHAS.md", "STATUS.md" ], "tests": [ { "command": "go test ./internal/controlapi/...", "exit_code": 0 }, { "command": "go test ./control-plane/cmd/control-plane/", "exit_code": 0 }, { "command": "go build ./...", "exit_code": 0 } ], "criteria": { "A provisioning deploy run is persisted to disk as it progresses (verified by reading the store back after the run advances)": "deployrunstore.go put() persists each frame via jsonstore.File atomically; proven by TestDeployRunStore_PersistsAcrossReopen (a frame put to one store is read back by a fresh store over the same path)", "A test that starts a deploy, simulates a control-plane restart mid-run, and asserts the run is resumed to completion OR reconciled to a terminal failed state — never silently lost and never stuck reporting running indefinitely": "TestDeployRunStore_ReconcilesInterruptedRunToFailed: a non-terminal frame persisted, then a fresh store (restart) reconciles it to a terminal clean-retry Failure (not lost, not still-running), and it survives a second restart; TestDeployRunStore_SettledRunSurvivesReconcile confirms a settled run is untouched", "The poll endpoint distinguishes never-deployed (404 / no record) from lost-run (a persisted, interrupted run surfaced as a failure) server-side": "TestProvisionDeploy_PollDistinguishesLostRunFrom404AfterRestart: over an HTTP handler reconstructed on the same store path, GET .../totara/deploy returns 200 + Failure (lost-run) while GET .../rimu/deploy returns 404 (never-deployed)", "The founding flow's persistence/resume behavior is unchanged (the new store follows its pattern; it does not modify it)": "No file under internal/founding changed (git diff touches only controlapi, control-plane main, docs, STATUS); the new store reuses internal/jsonstore, the same shared single-writer backing founding uses" }, "summary": "Persisted the provisioning deploy run to a disk-backed store that reconciles an interrupted run to a terminal failure on control-plane restart, so the poll endpoint distinguishes never-deployed (404) from lost-run (failure) at the source.", "blockers": [] } ``` </details>
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#1350
No description provided.