Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move definition of Pod*Exceptions to pod_generator #34346

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions airflow/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,15 +387,15 @@ class TaskDeferralError(AirflowException):
# 2) if you have new provider, both provider and pod generator will throw the
# "airflow.providers.cncf.kubernetes" as it will be imported here from the provider.
try:
from airflow.providers.cncf.kubernetes.executors.kubernetes_executor import PodMutationHookException
from airflow.providers.cncf.kubernetes.pod_generator import PodMutationHookException
except ImportError:

class PodMutationHookException(AirflowException): # type: ignore[no-redef]
"""Raised when exception happens during Pod Mutation Hook execution."""


try:
from airflow.providers.cncf.kubernetes.executors.kubernetes_executor import PodReconciliationError
from airflow.providers.cncf.kubernetes.pod_generator import PodReconciliationError
except ImportError:

class PodReconciliationError(AirflowException): # type: ignore[no-redef]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

from sqlalchemy import select, update

from airflow.exceptions import AirflowException
from airflow.providers.cncf.kubernetes.pod_generator import PodMutationHookException, PodReconciliationError

try:
from airflow.cli.cli_config import (
Expand Down Expand Up @@ -100,14 +100,6 @@
)


class PodMutationHookException(AirflowException):
"""Raised when exception happens during Pod Mutation Hook execution."""


class PodReconciliationError(AirflowException):
"""Raised when an error is encountered while trying to merge pod configs."""


# CLI Args
ARG_NAMESPACE = Arg(
("--namespace",),
Expand Down
13 changes: 9 additions & 4 deletions airflow/providers/cncf/kubernetes/pod_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,9 @@

from airflow.exceptions import (
AirflowConfigException,
AirflowException,
RemovedInAirflow3Warning,
)
from airflow.providers.cncf.kubernetes.executors.kubernetes_executor import (
PodMutationHookException,
PodReconciliationError,
)
from airflow.providers.cncf.kubernetes.kubernetes_helper_functions import add_pod_suffix, rand_str
from airflow.providers.cncf.kubernetes.pod_generator_deprecated import (
PodDefaults,
Expand All @@ -63,6 +60,14 @@
MAX_LABEL_LEN = 63


class PodMutationHookException(AirflowException):
"""Raised when exception happens during Pod Mutation Hook execution."""


class PodReconciliationError(AirflowException):
"""Raised when an error is encountered while trying to merge pod configs."""


def make_safe_label_value(string: str) -> str:
"""
Normalize a provided label to be of valid length and characters.
Expand Down