:py:mod:`astronomer.providers.cncf.kubernetes.triggers.wait_container` ====================================================================== .. py:module:: astronomer.providers.cncf.kubernetes.triggers.wait_container Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: astronomer.providers.cncf.kubernetes.triggers.wait_container.WaitContainerTrigger .. py:exception:: PodLaunchTimeoutException Bases: :py:obj:`airflow.exceptions.AirflowException` When pod does not leave the ``Pending`` phase within specified timeout. .. py:class:: 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) Bases: :py:obj:`airflow.triggers.base.BaseTrigger` First, waits for pod ``pod_name`` to reach running state within ``pending_phase_timeout``. Next, waits for ``container_name`` to reach a terminal state. :param kubernetes_conn_id: Airflow connection ID to use :param hook_params: kwargs for hook :param container_name: container to wait for :param pod_name: name of pod to monitor :param pod_namespace: pod namespace :param pending_phase_timeout: max time in seconds to wait for pod to leave pending phase :param poll_interval: number of seconds between reading pod state :param logging_interval: number of seconds to wait before kicking it back to the operator to print latest logs. If ``None`` will wait until container done. :param last_log_time: where to resume logs from .. py:method:: serialize() Returns the information needed to reconstruct this Trigger. :return: Tuple of (class path, keyword arguments needed to re-instantiate). .. py:method:: get_hook() :async: .. py:method:: wait_for_pod_start(v1_api) :async: Loops until pod phase leaves ``PENDING`` If timeout is reached, throws error. .. py:method:: wait_for_container_completion(v1_api) :async: 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. .. py:method:: run() :async: 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.