astronomer.providers.cncf.kubernetes.triggers.wait_container
¶
Module Contents¶
Classes¶
First, waits for pod |
- exception astronomer.providers.cncf.kubernetes.triggers.wait_container.PodLaunchTimeoutException[source]¶
Bases:
airflow.exceptions.AirflowException
When pod does not leave the
Pending
phase within specified timeout.
- class astronomer.providers.cncf.kubernetes.triggers.wait_container.WaitContainerTrigger(*, container_name, pod_name, pod_namespace, kubernetes_conn_id=None, hook_params=None, pending_phase_timeout=120, poll_interval=5, logging_interval=None, last_log_time=None)[source]¶
Bases:
airflow.triggers.base.BaseTrigger
First, waits for pod
pod_name
to reach running state withinpending_phase_timeout
. Next, waits forcontainer_name
to reach a terminal state.- Parameters:
kubernetes_conn_id (Optional[str]) – Airflow connection ID to use
hook_params (Optional[Dict[str, Any]]) – kwargs for hook
container_name (str) – container to wait for
pod_name (str) – name of pod to monitor
pod_namespace (str) – pod namespace
pending_phase_timeout (float) – max time in seconds to wait for pod to leave pending phase
poll_interval (float) – number of seconds between reading pod state
logging_interval (Optional[int]) – number of seconds to wait before kicking it back to the operator to print latest logs. If
None
will wait until container done.last_log_time (Optional[pendulum.DateTime]) – where to resume logs from
- serialize()[source]¶
Returns the information needed to reconstruct this Trigger.
- Returns:
Tuple of (class path, keyword arguments needed to re-instantiate).
- Return type:
Tuple[str, Dict[str, Any]]
- async wait_for_pod_start(v1_api)[source]¶
Loops until pod phase leaves
PENDING
If timeout is reached, throws error.
- async wait_for_container_completion(v1_api)[source]¶
Waits until container
self.container_name
is no longer in running state. If trigger is configured with a logging period, then will emit an event to resume the task for the purpose of fetching more logs.
- async run()[source]¶
Runs the trigger in an asynchronous context.
The trigger should yield an Event whenever it wants to fire off an event, and return None if it is finished. Single-event triggers should thus yield and then immediately return.
If it yields, it is likely that it will be resumed very quickly, but it may not be (e.g. if the workload is being moved to another triggerer process, or a multi-event trigger was being used for a single-event task defer).
In either case, Trigger classes should assume they will be persisted, and then rely on cleanup() being called when they are no longer needed.