control
Submit, read back and end the orchestrator's update hold.
What the orchestrator's /update/hold endpoints and its start-up sweep call.
Everything is read off the hold's own flow run (update_hold.flow): there is
only ever one live hold on a machine, and its Prefect state is its status.
Module
Functions
cancel_stale_update_holds
async def cancel_stale_update_holds( client: PrefectClient, *, created_before: datetime,) ‑> int:End every hold a previous orchestrator process left unfinished.
Their runner died with that process, so nothing else will end them: a paused one would stay paused, and a cancelling one would wait out Prefect's cancellation timeout. Only holds created before created_before are touched, so one the desktop app asked for since the restart is kept. Their slots lapse with their lease.
Arguments
client: An openPrefectClient.created_before: When this process started.
Returns How many holds were ended. Best effort per hold.
release_update_hold
async def release_update_hold( client: PrefectClient, *, waiting_only: bool = False,) ‑> uuid.UUID | None:Let the machine go: resume a ready hold, or cancel one still waiting.
A resumed hold releases its slots at once. A cancelled one is stopped by its runner, and the slots it had taken lapse with their lease, within a minute.
Arguments
client: An openPrefectClient.waiting_only: Leave a ready hold alone: the update may be installing under it, and its ready cap ends it.
Returns
The released hold, or None when none was live, it let go before this
release reached it, or it was ready and waiting_only was set.
Raises
UpdateHoldReleaseRefusedError: Prefect refused the change; the hold is still in force.
request_update_hold
async def request_update_hold( client: PrefectClient, *, max_wait_seconds: float, max_ready_seconds: float,) ‑> UpdateHoldView:Submit an update hold, or return the one already live.
Idempotent, and ends any hold that never started first. Returns without waiting for the hold to start; its status says when it is ready.
Arguments
client: An openPrefectClient.max_wait_seconds: How long running work may take to give the machine up.max_ready_seconds: How long to hold the machine for an install.
Returns The live hold.
update_hold_status
async def update_hold_status(client: PrefectClient) ‑> UpdateHoldView:Return the machine's update hold: the live one, else the newest.
Arguments
client: An openPrefectClient.
Returns
The hold's view; NONE when no hold was ever asked for.
Classes
UpdateHoldReleaseRefusedError
class UpdateHoldReleaseRefusedError(*args, **kwargs):Prefect refused to release a live update hold, which is still in force.
UpdateHoldStatus
class UpdateHoldStatus(*args, **kwds):Where the machine's update hold has got to.
Attributes
NONE: No hold has been asked for.WAITING: The hold is collecting the machine's background DAG slots as running work gives them up.READY: The hold holds every slot: the update can be installed.RELEASED: The hold has let the machine go.
Ancestors
UpdateHoldView
class UpdateHoldView( status: UpdateHoldStatus, reason: UpdateHoldReason | None = None, flow_run_id: uuid.UUID | None = None,):The machine's update hold, as the orchestrator reports it.
Attributes
status: Where the hold has got to.reason: Why a released hold let go;Noneotherwise.flow_run_id: The hold's flow run;Nonewhen there is none.
Variables
-
flow_run_id : uuid.UUID | None
-
reason : UpdateHoldReason | None
-
status : UpdateHoldStatus
Methods
as_dict
def as_dict(self) ‑> dict[str, typing.Any]:Return the view as the endpoint's JSON body.