Skip to content

Commit db38a6f

Browse files
authored
GKEPodHook ignores gcp_conn_id parameter. (#34194)
1 parent f70c107 commit db38a6f

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

airflow/providers/google/cloud/operators/kubernetes_engine.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,7 @@ def hook(self) -> GKEPodHook:
540540
)
541541

542542
hook = GKEPodHook(
543+
gcp_conn_id=self.gcp_conn_id,
543544
cluster_url=self._cluster_url,
544545
ssl_ca_cert=self._ssl_ca_cert,
545546
)

tests/providers/google/cloud/operators/test_kubernetes_engine.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,43 @@ def test_cluster_info(self, get_cluster_mock, use_internal_ip):
320320
assert cluster_url == CLUSTER_PRIVATE_URL if use_internal_ip else CLUSTER_URL
321321
assert ssl_ca_cert == SSL_CA_CERT
322322

323+
def test_default_gcp_conn_id(self):
324+
gke_op = GKEStartPodOperator(
325+
project_id=TEST_GCP_PROJECT_ID,
326+
location=PROJECT_LOCATION,
327+
cluster_name=CLUSTER_NAME,
328+
task_id=PROJECT_TASK_ID,
329+
name=TASK_NAME,
330+
namespace=NAMESPACE,
331+
image=IMAGE,
332+
)
333+
gke_op._cluster_url = CLUSTER_URL
334+
gke_op._ssl_ca_cert = SSL_CA_CERT
335+
hook = gke_op.hook
336+
337+
assert hook.gcp_conn_id == "google_cloud_default"
338+
339+
@mock.patch(
340+
"airflow.providers.google.common.hooks.base_google.GoogleBaseHook.get_connection",
341+
return_value=Connection(conn_id="test_conn"),
342+
)
343+
def test_gcp_conn_id(self, get_con_mock):
344+
gke_op = GKEStartPodOperator(
345+
project_id=TEST_GCP_PROJECT_ID,
346+
location=PROJECT_LOCATION,
347+
cluster_name=CLUSTER_NAME,
348+
task_id=PROJECT_TASK_ID,
349+
name=TASK_NAME,
350+
namespace=NAMESPACE,
351+
image=IMAGE,
352+
gcp_conn_id="test_conn",
353+
)
354+
gke_op._cluster_url = CLUSTER_URL
355+
gke_op._ssl_ca_cert = SSL_CA_CERT
356+
hook = gke_op.hook
357+
358+
assert hook.gcp_conn_id == "test_conn"
359+
323360
@pytest.mark.parametrize(
324361
"compatible_kpo, kwargs, expected_attributes",
325362
[

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy