airflow.providers.cncf.kubernetes.utils.pod_launcher

Launches PODs

Module Contents

airflow.providers.cncf.kubernetes.utils.pod_launcher.should_retry_start_pod(exception: Exception)[source]
Check if an Exception indicates a transient error and warrants retrying
class airflow.providers.cncf.kubernetes.utils.pod_launcher.PodStatus[source]

Status of the PODs

PENDING = pending[source]
RUNNING = running[source]
FAILED = failed[source]
SUCCEEDED = succeeded[source]
class airflow.providers.cncf.kubernetes.utils.pod_launcher.PodLauncher(kube_client: client.CoreV1Api = None, in_cluster: bool = True, cluster_context: Optional[str] = None, extract_xcom: bool = False)[source]

Bases: airflow.utils.log.logging_mixin.LoggingMixin

Launches PODS

run_pod_async(self, pod: V1Pod, **kwargs)[source]

Runs POD asynchronously

delete_pod(self, pod: V1Pod)[source]

Deletes POD

start_pod(self, pod: V1Pod, startup_timeout: int = 120)[source]

Launches the pod synchronously and waits for completion.

Parameters
  • pod --

  • startup_timeout -- Timeout for startup of the pod (if pod is pending for too long, fails task)

Returns

monitor_pod(self, pod: V1Pod, get_logs: bool)[source]

Monitors a pod and returns the final state, pod and xcom result

Parameters
  • pod -- pod spec that will be monitored

  • get_logs -- whether to read the logs locally

Returns

Tuple[State, Optional[str]]

parse_log_line(self, line: str)[source]

Parse K8s log line and returns the final state

Parameters

line (str) -- k8s log line

Returns

timestamp and log message

Return type

Tuple[str, str]

pod_not_started(self, pod: V1Pod)[source]

Tests if pod has not started

pod_is_running(self, pod: V1Pod)[source]

Tests if pod is running

base_container_is_running(self, pod: V1Pod)[source]

Tests if base container is running

read_pod_logs(self, pod: V1Pod, tail_lines: Optional[int] = None, timestamps: bool = False, since_seconds: Optional[int] = None)[source]

Reads log from the POD

read_pod_events(self, pod)[source]

Reads events from the POD

read_pod(self, pod: V1Pod)[source]

Read POD information

process_status(self, job_id, status)[source]

Process status information for the JOB

Was this entry helpful?