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 0239776 Deprecate default pod name in EKSPodOperator (#18036)
0239776 is described below
commit 02397761af7ed77b0e7c4f4d8de34d8a861c5b40
Author: Kamil BreguĊa <[email protected]>
AuthorDate: Sun Sep 12 19:56:26 2021 +0200
Deprecate default pod name in EKSPodOperator (#18036)
---
.../amazon/aws/example_dags/example_eks_templated.py | 1 +
.../aws/example_dags/example_eks_using_defaults.py | 1 +
.../aws/example_dags/example_eks_with_nodegroups.py | 1 +
airflow/providers/amazon/aws/operators/eks.py | 16 +++++++++++++++-
tests/providers/amazon/aws/operators/test_eks.py | 1 +
5 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/airflow/providers/amazon/aws/example_dags/example_eks_templated.py
b/airflow/providers/amazon/aws/example_dags/example_eks_templated.py
index 67f426d..330c3b4 100644
--- a/airflow/providers/amazon/aws/example_dags/example_eks_templated.py
+++ b/airflow/providers/amazon/aws/example_dags/example_eks_templated.py
@@ -85,6 +85,7 @@ with DAG(
start_pod = EKSPodOperator(
task_id="run_pod",
+ pod_name="start_pod",
cluster_name="{{ dag_run.conf['cluster_name'] }}",
image="amazon/aws-cli:latest",
cmds=["sh", "-c", "ls"],
diff --git
a/airflow/providers/amazon/aws/example_dags/example_eks_using_defaults.py
b/airflow/providers/amazon/aws/example_dags/example_eks_using_defaults.py
index 63aa853..12a80fb 100644
--- a/airflow/providers/amazon/aws/example_dags/example_eks_using_defaults.py
+++ b/airflow/providers/amazon/aws/example_dags/example_eks_using_defaults.py
@@ -71,6 +71,7 @@ with DAG(
start_pod = EKSPodOperator(
task_id="run_pod",
+ pod_name="run_pod",
cluster_name=CLUSTER_NAME,
image="amazon/aws-cli:latest",
cmds=["sh", "-c", "ls"],
diff --git
a/airflow/providers/amazon/aws/example_dags/example_eks_with_nodegroups.py
b/airflow/providers/amazon/aws/example_dags/example_eks_with_nodegroups.py
index 4e54885..89f94ed 100644
--- a/airflow/providers/amazon/aws/example_dags/example_eks_with_nodegroups.py
+++ b/airflow/providers/amazon/aws/example_dags/example_eks_with_nodegroups.py
@@ -86,6 +86,7 @@ with DAG(
# [START howto_operator_eks_pod_operator]
start_pod = EKSPodOperator(
task_id="run_pod",
+ pod_name="run_pod",
cluster_name=CLUSTER_NAME,
image="amazon/aws-cli:latest",
cmds=["sh", "-c", "ls"],
diff --git a/airflow/providers/amazon/aws/operators/eks.py
b/airflow/providers/amazon/aws/operators/eks.py
index 9fce83f..35f958e 100644
--- a/airflow/providers/amazon/aws/operators/eks.py
+++ b/airflow/providers/amazon/aws/operators/eks.py
@@ -21,6 +21,7 @@ from datetime import datetime
from time import sleep
from typing import Dict, Iterable, List, Optional
+from airflow import AirflowException
from airflow.models import BaseOperator
from airflow.providers.amazon.aws.hooks.eks import ClusterStates, EKSHook
from airflow.providers.cncf.kubernetes.operators.kubernetes_pod import
KubernetesPodOperator
@@ -414,12 +415,21 @@ class EKSPodOperator(KubernetesPodOperator):
in_cluster: bool = False,
namespace: str = DEFAULT_NAMESPACE_NAME,
pod_context: str = None,
- pod_name: str = DEFAULT_POD_NAME,
+ pod_name: str = None,
pod_username: str = None,
aws_conn_id: str = DEFAULT_CONN_ID,
region: Optional[str] = None,
**kwargs,
) -> None:
+ if pod_name is None:
+ warnings.warn(
+ "Default value of pod name is deprecated. "
+ "We recommend that you pass pod name explicitly. ",
+ DeprecationWarning,
+ stacklevel=2,
+ )
+ pod_name = DEFAULT_POD_NAME
+
self.cluster_name = cluster_name
self.in_cluster = in_cluster
self.namespace = namespace
@@ -446,6 +456,10 @@ class EKSPodOperator(KubernetesPodOperator):
DeprecationWarning,
stacklevel=2,
)
+ # There is no need to manage the kube_config file, as it will be
generated automatically.
+ # All Kubernetes parameters (except config_file) are also valid for
the EKSPodOperator.
+ if self.config_file:
+ raise AirflowException("The config_file is not an allowed
parameter for the EKSPodOperator.")
def execute(self, context):
eks_hook = EKSHook(
diff --git a/tests/providers/amazon/aws/operators/test_eks.py
b/tests/providers/amazon/aws/operators/test_eks.py
index 864bb67..87e5a2a 100644
--- a/tests/providers/amazon/aws/operators/test_eks.py
+++ b/tests/providers/amazon/aws/operators/test_eks.py
@@ -174,6 +174,7 @@ class TestEKSPodOperator(unittest.TestCase):
op = EKSPodOperator(
task_id="run_pod",
+ pod_name="run_pod",
cluster_name=CLUSTER_NAME,
image="amazon/aws-cli:latest",
cmds=["sh", "-c", "ls"],