Skip to content

Commit b68d193

Browse files
authored
Add error check for config_file parameter in GKEStartPodOperator (#17700)
1 parent bee48f3 commit b68d193

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

β€Žairflow/providers/google/cloud/operators/kubernetes_engine.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,10 @@ def __init__(
292292
"Credentials (ADC) strategy for authorization, create an empty connection "
293293
"called `google_cloud_default`.",
294294
)
295+
# There is no need to manage the kube_config file, as it will be generated automatically.
296+
# All Kubernetes parameters (except config_file) are also valid for the GKEStartPodOperator.
297+
if self.config_file:
298+
raise AirflowException("config_file is not an allowed parameter for the GKEStartPodOperator.")
295299

296300
def execute(self, context) -> Optional[str]:
297301
hook = GoogleBaseHook(gcp_conn_id=self.gcp_conn_id)

β€Žtests/providers/google/cloud/operators/test_kubernetes_engine.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,19 @@ def test_execute(self, file_mock, mock_execute_in_subprocess, mock_gcp_hook, exe
182182

183183
assert self.gke_op.config_file == FILE_NAME
184184

185+
def test_config_file_throws_error(self):
186+
with pytest.raises(AirflowException):
187+
GKEStartPodOperator(
188+
project_id=TEST_GCP_PROJECT_ID,
189+
location=PROJECT_LOCATION,
190+
cluster_name=CLUSTER_NAME,
191+
task_id=PROJECT_TASK_ID,
192+
name=TASK_NAME,
193+
namespace=NAMESPACE,
194+
image=IMAGE,
195+
config_file="/path/to/alternative/kubeconfig",
196+
)
197+
185198
@mock.patch.dict(os.environ, {})
186199
@mock.patch(
187200
"airflow.hooks.base.BaseHook.get_connections",

0 commit comments

Comments
 (0)