ironic.common.redfish.taskmonitor module

Async Task Monitor for Redfish asynchronous operations.

class ironic.common.redfish.taskmonitor.AsyncTaskMonitor(connector, task_monitor_uri, response=None)[source]

Bases: object

Monitor for asynchronous Redfish operations.

This class tracks the progress of long-running Redfish operations that return HTTP 202 Accepted with a task monitor URI.

property cancellable

Check if the task can be cancelled.

Reports False until the monitor has polled at least once, the same answer it gives for a task whose response carries no Allow header: permission to DELETE is something the BMC states, not something to assume on its behalf. A caller that needs this on a monitor built from a URI alone should refresh() first.

Returns:

True if task is cancellable, False otherwise

async check_is_processing()[source]

Refresh and check if the task is still processing.

Returns:

True if task is processing, False otherwise

async static from_response(connector, response, target_uri)[source]

Create TaskMonitor from an HTTP response.

Parameters:
  • connector – AsyncConnector instance

  • response – httpx.Response from async operation

  • target_uri – URI that initiated the async operation

Returns:

AsyncTaskMonitor instance

Raises:

MissingHeaderError if Location header is missing

property is_processing

Check if the task is still processing.

A monitor built from a task monitor URI alone has not polled the BMC yet, and an unpolled task counts as still processing. The other answer is far worse: reporting a task as finished before anything has been asked would let wait() return immediately and callers treat an operation still running on the BMC as complete. The first refresh() replaces the assumption with what the BMC actually says.

Returns:

True if task is processing, False otherwise

async refresh()[source]

Refresh the task state.

Retrieves the current state of the task from the BMC.

Raises:

ConnectionError on request failures

Raises:

Various HTTP exceptions on HTTP errors

property response

Get the raw response.

Returns:

httpx.Response object

property sleep_for

Get recommended sleep duration before next poll.

Uses Retry-After header if present, defaults to 1 second. Before the first poll there is no response to take a hint from, so the default applies there too.

Returns:

Number of seconds to wait before next poll

property task_monitor_uri

Get the task monitor URI.

Returns:

The task monitor URI

property task_resource

Get the task resource.

Returns:

AsyncResource for the task, or None if not available

async wait(timeout_sec)[source]

Wait for the task to complete.

Polls the task monitor URI until the task completes or the timeout expires. Before every poll the Retry-After hint of the response currently held is honoured, so the first poll does not happen before the BMC asked for it. The sleep is capped to the time left of the budget, so a Retry-After longer than the timeout cannot stretch the wait: the deadline still buys one last poll, and the task is only declared timed out once that poll reports it as still processing.

Each poll is bounded too, so an unresponsive BMC cannot stretch the wait either. Without that bound a single poll could occupy the connector’s whole retry chain - several attempts of its default request timeout plus backoff - and run for minutes regardless of the budget given here. A poll is allowed the time left of the budget, or MIN_POLL_TIMEOUT when the budget is already spent, which puts the worst case for this call at timeout_sec plus one poll. Abandoning a poll loses nothing: it is a GET, and the next one re-reads the same state.

Note that the bound applies to this call, not to the BMC. Callers that hold a resource for the duration still want their own deadline around it.

Parameters:

timeout_sec – Maximum time to wait in seconds

Raises:

ConnectionError when timeout is reached