airflow.providers.cncf.kubernetes.utils.pod_manager
¶
Launches PODs.
Module Contents¶
Classes¶
Possible pod phases. |
|
Protocol to define methods relied upon by KubernetesPodOperator. |
|
Return the status of the pod and last log time when exiting from fetch_container_logs. |
|
Create, monitor, and otherwise interact with Kubernetes pods for use with the KubernetesPodOperator. |
|
Action to take when the pod finishes. |
Functions¶
|
Check if an Exception indicates a transient error and warrants retrying. |
|
Retrieve container status. |
|
Examine V1Pod |
|
Examine V1Pod |
|
Examine V1Pod |
|
Examine V1Pod |
|
Examine V1Pod |
|
|
|
Check if the line is a log group marker like ::group:: or ::endgroup::. |
- exception airflow.providers.cncf.kubernetes.utils.pod_manager.PodLaunchFailedException[source]¶
Bases:
airflow.exceptions.AirflowException
When pod launching fails in KubernetesPodOperator.
- airflow.providers.cncf.kubernetes.utils.pod_manager.should_retry_start_pod(exception)[source]¶
Check if an Exception indicates a transient error and warrants retrying.
- class airflow.providers.cncf.kubernetes.utils.pod_manager.PodPhase[source]¶
Possible pod phases.
See https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-phase.
- class airflow.providers.cncf.kubernetes.utils.pod_manager.PodOperatorHookProtocol[source]¶
Bases:
Protocol
Protocol to define methods relied upon by KubernetesPodOperator.
Subclasses of KubernetesPodOperator, such as GKEStartPodOperator, may use hooks that don’t extend KubernetesHook. We use this protocol to document the methods used by KPO and ensure that these methods exist on such other hooks.
- property is_in_cluster: bool[source]¶
Expose whether the hook is configured with
load_incluster_config
or not.
- airflow.providers.cncf.kubernetes.utils.pod_manager.get_container_status(pod, container_name)[source]¶
Retrieve container status.
- airflow.providers.cncf.kubernetes.utils.pod_manager.container_is_running(pod, container_name)[source]¶
Examine V1Pod
pod
to determine whethercontainer_name
is running.If that container is present and running, returns True. Returns False otherwise.
- airflow.providers.cncf.kubernetes.utils.pod_manager.container_is_completed(pod, container_name)[source]¶
Examine V1Pod
pod
to determine whethercontainer_name
is completed.If that container is present and completed, returns True. Returns False otherwise.
- airflow.providers.cncf.kubernetes.utils.pod_manager.container_is_succeeded(pod, container_name)[source]¶
Examine V1Pod
pod
to determine whethercontainer_name
is completed and succeeded.If that container is present and completed and succeeded, returns True. Returns False otherwise.
- airflow.providers.cncf.kubernetes.utils.pod_manager.container_is_wait(pod, container_name)[source]¶
Examine V1Pod
pod
to determine whethercontainer_name
is waiting.If that container is present and waiting, returns True. Returns False otherwise.
- airflow.providers.cncf.kubernetes.utils.pod_manager.container_is_terminated(pod, container_name)[source]¶
Examine V1Pod
pod
to determine whethercontainer_name
is terminated.If that container is present and terminated, returns True. Returns False otherwise.
- airflow.providers.cncf.kubernetes.utils.pod_manager.get_container_termination_message(pod, container_name)[source]¶
- airflow.providers.cncf.kubernetes.utils.pod_manager.check_exception_is_kubernetes_api_unauthorized(exc)[source]¶
- exception airflow.providers.cncf.kubernetes.utils.pod_manager.PodLaunchTimeoutException[source]¶
Bases:
airflow.exceptions.AirflowException
When pod does not leave the
Pending
phase within specified timeout.
- exception airflow.providers.cncf.kubernetes.utils.pod_manager.PodNotFoundException[source]¶
Bases:
airflow.exceptions.AirflowException
Expected pod does not exist in kube-api.
- class airflow.providers.cncf.kubernetes.utils.pod_manager.PodLoggingStatus[source]¶
Return the status of the pod and last log time when exiting from fetch_container_logs.
- class airflow.providers.cncf.kubernetes.utils.pod_manager.PodManager(kube_client, callbacks=None)[source]¶
Bases:
airflow.utils.log.logging_mixin.LoggingMixin
Create, monitor, and otherwise interact with Kubernetes pods for use with the KubernetesPodOperator.
- await_pod_start(pod, startup_timeout=120, startup_check_interval=1)[source]¶
Wait for the pod to reach phase other than
Pending
.
- await_container_completion(pod, container_name)[source]¶
Wait for the given container in the given pod to be completed.
- Parameters
pod (kubernetes.client.models.v1_pod.V1Pod) – pod spec that will be monitored
container_name (str) – name of the container within the pod to monitor
- await_pod_completion(pod, istio_enabled=False, container_name='base')[source]¶
Monitor a pod and return the final state.
- container_is_terminated(pod, container_name)[source]¶
Read pod and checks if container is terminated.
- read_pod_logs(pod, container_name, tail_lines=None, timestamps=False, since_seconds=None, follow=True, post_termination_timeout=120, **kwargs)[source]¶
Read log from the POD.