fix(update): a rolled-back service pause keeps the adopted orphan set owed

When the service pause fails and everything this run stopped is restarted
in-line, the record used to be discharged outright, dropping a set adopted
from an earlier killed update. Only this run's part is discharged now; the
adopted set goes back on disk unowned for the next launch.

(cherry picked from commit 8f82322877ed852b16739716c2712b4c7ec7530f)
(cherry picked from commit 41f91c428c79b11ef14f1a44694d0e861c07d656)
This commit is contained in:
Teknium
2026-10-03 12:45:57 -07:00
parent 964b3fd4f6
commit 90525c4b8e
2 changed files with 11 additions and 1 deletions

View File

@@ -956,7 +956,7 @@ def _pause_windows_gateways_for_update() -> dict | None:
token = _pause_windows_gateway_services(service_gateways, token, profiles, unmapped)
except RuntimeError as exc:
if "rollback failures" not in str(exc): # everything stopped was restarted in-line
pause_record.discharge(intended)
pause_record.abandon_pause(intended, adopted)
raise
return pause_record.finish_pause(token, intended, adopted)

View File

@@ -317,6 +317,16 @@ def finish_pause(token: dict, intended: dict, adopted: dict | None) -> dict:
return token
def abandon_pause(intended: dict, adopted: dict | None) -> None:
"""This run's own stops were rolled back in-line: only an adopted orphan set is still owed,
and it goes back on disk unowned for the next launch."""
if adopted is None:
discharge(intended)
return
carried = {key: intended[key] for key in ("pause_id", "pre_sha", "dirty_at_pause") if key in intended}
write({**adopted, **carried}, owner=UNOWNED)
def drop_never_stopped(token: dict) -> dict:
"""Entries whose recorded process is still the same live incarnation were never stopped."""
alive = {pid for pid, ct in (token.get("identities") or {}).items()