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

Deprecate default pod name in EKSPodOperator #18036

Merged
merged 2 commits into from
Sep 12, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@

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"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@

start_pod = EKSPodOperator(
task_id="run_pod",
pod_name="run_pod",
cluster_name=CLUSTER_NAME,
image="amazon/aws-cli:latest",
cmds=["sh", "-c", "ls"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
# [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"],
Expand Down
16 changes: 15 additions & 1 deletion airflow/providers/amazon/aws/operators/eks.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
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
Expand Down Expand Up @@ -414,12 +415,21 @@ def __init__(
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
Expand All @@ -446,6 +456,10 @@ def __init__(
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(
Expand Down
1 change: 1 addition & 0 deletions tests/providers/amazon/aws/operators/test_eks.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ def test_existing_nodegroup(

op = EKSPodOperator(
task_id="run_pod",
pod_name="run_pod",
cluster_name=CLUSTER_NAME,
image="amazon/aws-cli:latest",
cmds=["sh", "-c", "ls"],
Expand Down