23 lines
1007 B
Python
23 lines
1007 B
Python
"""Reconcile interrupted disposable deployments without guessing intent."""
|
|
|
|
from core.locking import DeploymentLock
|
|
|
|
|
|
def reconcile(planner, rollback, services, *, confirmation=None, fingerprint=None):
|
|
if (confirmation is None) != (fingerprint is None):
|
|
raise ValueError("Both recovery confirmation and plan fingerprint are required")
|
|
with DeploymentLock(planner.lock_path):
|
|
plan = planner._inspect()
|
|
if plan["status"] in {"CLEAR", "VERIFIED"}:
|
|
if confirmation is not None:
|
|
raise ValueError("There is no eligible interrupted activation")
|
|
return plan
|
|
if confirmation is None:
|
|
services.quiesce()
|
|
if not services.stopped():
|
|
raise RuntimeError("Unable to contain interrupted deployment")
|
|
return plan
|
|
if rollback.planner is not planner:
|
|
raise ValueError("Rollback uses different transaction state")
|
|
return rollback._execute(confirmation, fingerprint)
|