Source code for airflow.providers.cncf.kubernetes.executors.kubernetes_executor_types
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Literal, NamedTuple, TypedDict
if TYPE_CHECKING:
from collections.abc import Sequence
from airflow.models.taskinstance import TaskInstanceKey
from airflow.utils.state import TaskInstanceState
[docs]
class FailureDetails(TypedDict, total=False):
"""Detailed information about pod/container failure."""
[docs]
pod_message: str | None
[docs]
container_state: str | None
[docs]
container_reason: str | None
[docs]
container_message: str | None
[docs]
container_type: Literal["init", "main"] | None
[docs]
container_name: str | None
[docs]
class KubernetesResults(NamedTuple):
"""Results from Kubernetes task execution."""
[docs]
state: TaskInstanceState | str | None
[docs]
failure_details: FailureDetails | None
[docs]
class KubernetesWatch(NamedTuple):
"""Watch event data from Kubernetes pods."""
[docs]
state: TaskInstanceState | str | None
[docs]
annotations: dict[str, str]
[docs]
failure_details: FailureDetails | None
# TODO: Remove after Airflow 2 support is removed
[docs]
CommandType = "Sequence[str]"
[docs]
class KubernetesJob(NamedTuple):
"""Job definition for Kubernetes execution."""
[docs]
kube_executor_config: Any
[docs]
pod_template_file: str | None
[docs]
ALL_NAMESPACES = "ALL_NAMESPACES"
[docs]
POD_EXECUTOR_DONE_KEY = "airflow_executor_done"
[docs]
POD_REVOKED_KEY = "airflow_pod_revoked"
"""Label to indicate pod revoked by executor.
When executor the executor revokes a task, the pod deletion is the result of
the revocation. So we don't want it to process that as an external deletion.
So we want events on a revoked pod to be ignored.
:meta private:
"""