AlejandroMorgante commented on code in PR #72542:
URL: https://github.com/apache/airflow/pull/72542#discussion_r4178088303


##########
providers/amazon/src/airflow/providers/amazon/aws/operators/eks.py:
##########
@@ -47,10 +47,28 @@
     build_resource_in_use_retry_args,
     validate_execute_complete_event,
 )
-from airflow.providers.amazon.aws.utils.mixins import aws_template_fields
+from airflow.providers.amazon.aws.utils.mixins import AwsHookParams, 
aws_template_fields
 from airflow.providers.amazon.aws.utils.waiter_with_logging import wait
 from airflow.providers.cncf.kubernetes.utils.pod_manager import OnFinishAction
-from airflow.providers.common.compat.sdk import AirflowException, conf
+from airflow.providers.common.compat.sdk import (
+    AirflowException,
+    AirflowOptionalProviderFeatureException,
+    BaseOperator,
+    conf,
+)
+
+try:
+    from airflow.providers.cncf.kubernetes.operators.pod_exec import 
KubernetesPodExecOperator
+except ImportError:
+
+    class KubernetesPodExecOperator(BaseOperator):  # type: ignore[no-redef]
+        """Keep existing EKS operators importable with older Kubernetes 
providers."""
+
+        def __init__(self, **kwargs):
+            raise AirflowOptionalProviderFeatureException(
+                "EksPodExecOperator requires 
apache-airflow-providers-cncf-kubernetes>=10.22.0."
+            )

Review Comment:
   I based this on the existing backward-compatible import fallback in the EKS 
module 
<https://github.com/apache/airflow/blob/503e8072065e1aa15f773e1499e15eedb254e031/providers/amazon/src/airflow/providers/amazon/aws/operators/eks.py#L55-L61>
   
   The difference is that `KubernetesPodExecOperator` has no equivalent in 
older versions of the cncf-kubernetes provider. This fallback keeps existing 
EKS operators importable and only raises an error when someone tries to 
instantiate `EksPodExecOperator` without the required provider version.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to