This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new de92a81f00 Move definition of Pod*Exceptions to pod_generator (#34346)
de92a81f00 is described below
commit de92a81f002e6c1b3e74ad9d074438b65acb87b6
Author: Jarek Potiuk <[email protected]>
AuthorDate: Wed Sep 13 20:51:52 2023 +0200
Move definition of Pod*Exceptions to pod_generator (#34346)
The #32767 has moved all k8s classes to cncf.kubernetes provider,
however there was a mistake with location of Pod*Exceptions - rather
than in pod_manager they remained defined in the kubernetes_executor
package - which has the side-effect that trying to import them
in Airflow Pre 2.7 raised the
"You should not use the provider's executors in this version of
Airflow." error.
This change moves the exceptions to the pod_generator package
to fix the problem.
---
airflow/exceptions.py | 4 ++--
.../cncf/kubernetes/executors/kubernetes_executor.py | 10 +---------
airflow/providers/cncf/kubernetes/pod_generator.py | 13 +++++++++----
3 files changed, 12 insertions(+), 15 deletions(-)
diff --git a/airflow/exceptions.py b/airflow/exceptions.py
index 0840e801a1..2ca75cbbf8 100644
--- a/airflow/exceptions.py
+++ b/airflow/exceptions.py
@@ -387,7 +387,7 @@ 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]
@@ -395,7 +395,7 @@ except ImportError:
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]
diff --git a/airflow/providers/cncf/kubernetes/executors/kubernetes_executor.py
b/airflow/providers/cncf/kubernetes/executors/kubernetes_executor.py
index a0825d1d62..3780717685 100644
--- a/airflow/providers/cncf/kubernetes/executors/kubernetes_executor.py
+++ b/airflow/providers/cncf/kubernetes/executors/kubernetes_executor.py
@@ -36,7 +36,7 @@ from typing import TYPE_CHECKING, Any, Sequence
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 (
@@ -100,14 +100,6 @@ if TYPE_CHECKING:
)
-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",),
diff --git a/airflow/providers/cncf/kubernetes/pod_generator.py
b/airflow/providers/cncf/kubernetes/pod_generator.py
index c824fda7b4..e6d5e316b6 100644
--- a/airflow/providers/cncf/kubernetes/pod_generator.py
+++ b/airflow/providers/cncf/kubernetes/pod_generator.py
@@ -38,12 +38,9 @@ from kubernetes.client.api_client import ApiClient
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,
@@ -63,6 +60,14 @@ log = logging.getLogger(__name__)
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.