updates: a saved update policy is only in memory — SetPolicy/SetChannel never persist, the 204 is answered first, and a control-plane restart inside the gap restores the old policy #1975

Closed
opened 2026-09-28 22:27:02 +00:00 by ben · 2 comments
Owner

What's true today (seen live on Whakatōhea Demo, 2026-09-28; code on main @ be126a6b)

The steward's update policy is saved to memory and answered as saved. It reaches disk only when something else saves the store.

  • Orchestrator.SetPolicy and Orchestrator.SetChannel (internal/update/policy.go) assign o.store.policy and return. Neither calls o.store.save(), and neither returns an error.
  • POST /api/v1/updates/policy answers 204 straight after (internal/controlapi/updates.go).
  • The document is next written by whatever saves it — in practice Poll's deferred save, up to 5 minutes later.

Observed: at 22:24:01Z the window was set to 11:00–13:00 (204; GET /api/v1/updates/policy read it back). At 22:25:03Z and 22:26:00Z /var/lib/idss/update.json still held "window":{"start":"","end":""} — last written at 22:23:27Z by the poll before the change.

Why it matters

A control plane that restarts inside that gap comes back on the OLD policy, and the steward was told the new one was saved. The update lane restarts the control plane by design (ADR 0259): a steward who narrows the window, or turns automatic updates off, moments before a rollout's self-restart loses the change — and the next release applies under the policy they had just replaced. Same for a channel change or a pin (SetChannel): a pin that does not survive a restart is not a pin.

What to build

  • SetPolicy and SetChannel persist before they return, and return the save's error.
  • The two handlers answer 204 only after the save; a failed save is a 5xx Problem, never a 204.
  • The UpdateService seam and its fakes carry the error.

Acceptance

  • Given a durable store, When SetPolicy returns, Then a fresh Store loaded from the same backend reads the new security mode, feature mode and window — with no poll, rollout or tick in between
  • The same for SetChannel: a Matou channel, a pin, a fork
  • Given a backend whose save fails, Then POST /api/v1/updates/policy and POST /api/v1/updates/channel answer a 5xx Problem and the in-memory policy is unchanged
  • A red-first test: the persistence test fails on main before the fix
  • GOTCHAS entry (a 204 that was only a memory write), STATUS.md
## Parent: #1562 — related: #1633 (durable update store), #1635, #1850 ## What's true today (seen live on Whakatōhea Demo, 2026-09-28; code on `main` @ `be126a6b`) The steward's update policy is saved to memory and answered as saved. It reaches disk only when something else saves the store. - `Orchestrator.SetPolicy` and `Orchestrator.SetChannel` (`internal/update/policy.go`) assign `o.store.policy` and return. Neither calls `o.store.save()`, and neither returns an error. - `POST /api/v1/updates/policy` answers **204** straight after (`internal/controlapi/updates.go`). - The document is next written by whatever saves it — in practice `Poll`'s deferred save, up to 5 minutes later. Observed: at 22:24:01Z the window was set to 11:00–13:00 (204; `GET /api/v1/updates/policy` read it back). At 22:25:03Z and 22:26:00Z `/var/lib/idss/update.json` still held `"window":{"start":"","end":""}` — last written at 22:23:27Z by the poll before the change. ## Why it matters A control plane that restarts inside that gap comes back on the OLD policy, and the steward was told the new one was saved. The update lane restarts the control plane by design (ADR 0259): a steward who narrows the window, or turns automatic updates off, moments before a rollout's self-restart loses the change — and the next release applies under the policy they had just replaced. Same for a channel change or a pin (`SetChannel`): a pin that does not survive a restart is not a pin. ## What to build - `SetPolicy` and `SetChannel` persist before they return, and return the save's error. - The two handlers answer 204 only after the save; a failed save is a 5xx Problem, never a 204. - The `UpdateService` seam and its fakes carry the error. ## Acceptance - [ ] Given a durable store, When `SetPolicy` returns, Then a fresh `Store` loaded from the same backend reads the new security mode, feature mode and window — with no poll, rollout or tick in between - [ ] The same for `SetChannel`: a Matou channel, a pin, a fork - [ ] Given a backend whose save fails, Then `POST /api/v1/updates/policy` and `POST /api/v1/updates/channel` answer a 5xx Problem and the in-memory policy is unchanged - [ ] A red-first test: the persistence test fails on `main` before the fix - [ ] GOTCHAS entry (a 204 that was only a memory write), STATUS.md

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

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

close-report for #1975 — status success

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

envelope
{
  "issue": 1975,
  "status": "success",
  "commits": [
    "096505751025e0ed23bc2e8a1449188f62c013ee"
  ],
  "changed_files": [
    "STATUS.md",
    "docs/GOTCHAS.md",
    "internal/controlapi/updates.go",
    "internal/controlapi/updates_integration_test.go",
    "internal/update/policy.go",
    "internal/update/policy_persist_test.go",
    "internal/update/policy_test.go",
    "internal/update/rollback_test.go",
    "packages/openapi-spec/openapi.yaml"
  ],
  "tests": [
    {
      "command": "go test ./internal/update/ ./internal/controlapi/",
      "exit_code": 0
    },
    {
      "command": "go build ./... && go vet ./... && golangci-lint run ./... (full pre-push Go gate, main module + broker + dev tags)",
      "exit_code": 0
    }
  ],
  "criteria": {
    "Given a durable store, When SetPolicy returns, Then a fresh Store loaded from the same backend reads the new security mode, feature mode and window — with no poll, rollout or tick in between": "internal/update/policy.go SetPolicy now save()s before returning; internal/update/policy_persist_test.go TestSetPolicy_PersistsBeforeReturning reopens a fresh Store from the same MemoryBackend (no poll/tick) and reads ModeNever/ModeNever + 11:00-13:00",
    "The same for SetChannel: a Matou channel, a pin, a fork": "internal/update/policy.go SetChannel save()s before returning; TestSetChannel_PersistsBeforeReturning cases matou-channel/pin/fork each reopen a fresh Store and read the new channel and Pinned flag",
    "Given a backend whose save fails, Then POST /api/v1/updates/policy and POST /api/v1/updates/channel answer a 5xx Problem and the in-memory policy is unchanged": "internal/controlapi/updates.go maps a failed save to 500 policy_not_saved/channel_not_saved; TestUpdatesHandler_SetPolicyFailedSaveIs5xx and TestUpdatesHandler_SetChannelFailedSaveIs5xx assert 5xx + unchanged GET; unit TestSetPolicy_FailedSaveReturnsErrorAndLeavesPolicyUnchanged / TestSetChannel_... assert the error is returned and o.State().Policy is unchanged",
    "A red-first test: the persistence test fails on main before the fix": "Verified by neutering the save() call in policy.go (simulating main): TestSetPolicy_PersistsBeforeReturning and TestSetChannel_PersistsBeforeReturning FAIL ('reopened modes = apply-automatically/ask-me-first, want both never'; 'reopened channel = stable, want testing/a41f9c2/fork'); they pass only with the save",
    "GOTCHAS entry (a 204 that was only a memory write), STATUS.md": "docs/GOTCHAS.md #359 (204 that was only a memory write, Symptom/Cause/Rule); STATUS.md milestone log entry for #1975 DONE"
  },
  "binds": [
    {
      "symbol": "SetPolicy",
      "defined_in": "internal/update/policy.go"
    },
    {
      "symbol": "SetChannel",
      "defined_in": "internal/update/policy.go"
    }
  ],
  "summary": "The Updates policy/channel endpoints persist before answering 204: SetPolicy/SetChannel now save() and return the error, a failed save is a 5xx Problem with the in-memory policy unchanged.",
  "blockers": []
}
**close-report** for #1975 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 1975, "status": "success", "commits": [ "096505751025e0ed23bc2e8a1449188f62c013ee" ], "changed_files": [ "STATUS.md", "docs/GOTCHAS.md", "internal/controlapi/updates.go", "internal/controlapi/updates_integration_test.go", "internal/update/policy.go", "internal/update/policy_persist_test.go", "internal/update/policy_test.go", "internal/update/rollback_test.go", "packages/openapi-spec/openapi.yaml" ], "tests": [ { "command": "go test ./internal/update/ ./internal/controlapi/", "exit_code": 0 }, { "command": "go build ./... && go vet ./... && golangci-lint run ./... (full pre-push Go gate, main module + broker + dev tags)", "exit_code": 0 } ], "criteria": { "Given a durable store, When SetPolicy returns, Then a fresh Store loaded from the same backend reads the new security mode, feature mode and window — with no poll, rollout or tick in between": "internal/update/policy.go SetPolicy now save()s before returning; internal/update/policy_persist_test.go TestSetPolicy_PersistsBeforeReturning reopens a fresh Store from the same MemoryBackend (no poll/tick) and reads ModeNever/ModeNever + 11:00-13:00", "The same for SetChannel: a Matou channel, a pin, a fork": "internal/update/policy.go SetChannel save()s before returning; TestSetChannel_PersistsBeforeReturning cases matou-channel/pin/fork each reopen a fresh Store and read the new channel and Pinned flag", "Given a backend whose save fails, Then POST /api/v1/updates/policy and POST /api/v1/updates/channel answer a 5xx Problem and the in-memory policy is unchanged": "internal/controlapi/updates.go maps a failed save to 500 policy_not_saved/channel_not_saved; TestUpdatesHandler_SetPolicyFailedSaveIs5xx and TestUpdatesHandler_SetChannelFailedSaveIs5xx assert 5xx + unchanged GET; unit TestSetPolicy_FailedSaveReturnsErrorAndLeavesPolicyUnchanged / TestSetChannel_... assert the error is returned and o.State().Policy is unchanged", "A red-first test: the persistence test fails on main before the fix": "Verified by neutering the save() call in policy.go (simulating main): TestSetPolicy_PersistsBeforeReturning and TestSetChannel_PersistsBeforeReturning FAIL ('reopened modes = apply-automatically/ask-me-first, want both never'; 'reopened channel = stable, want testing/a41f9c2/fork'); they pass only with the save", "GOTCHAS entry (a 204 that was only a memory write), STATUS.md": "docs/GOTCHAS.md #359 (204 that was only a memory write, Symptom/Cause/Rule); STATUS.md milestone log entry for #1975 DONE" }, "binds": [ { "symbol": "SetPolicy", "defined_in": "internal/update/policy.go" }, { "symbol": "SetChannel", "defined_in": "internal/update/policy.go" } ], "summary": "The Updates policy/channel endpoints persist before answering 204: SetPolicy/SetChannel now save() and return the error, a failed save is a 5xx Problem with the in-memory policy unchanged.", "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.

Dependencies

No dependencies set.

Reference
Matou/idss#1975
No description provided.