Skip to content

Commit

Permalink
Fix kubernetes engine system test (#18548)
Browse files Browse the repository at this point in the history
- Add 'in_cluster=False' argument to 'GKEStartPodOperator'
- Change order of activating service account and setting project
  • Loading branch information
deedmitrij committed Sep 27, 2021
1 parent a458fcc commit 2fadf3c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Expand Up @@ -61,6 +61,7 @@
namespace="default",
image="perl",
name="test-pod",
in_cluster=False,
)

# [START howto_operator_gke_start_pod_xcom]
Expand All @@ -74,6 +75,7 @@
image="alpine",
cmds=["sh", "-c", 'mkdir -p /airflow/xcom/;echo \'[1,2,3,4]\' > /airflow/xcom/return.json'],
name="test-pod-xcom",
in_cluster=False,
)
# [END howto_operator_gke_start_pod_xcom]

Expand Down
6 changes: 3 additions & 3 deletions airflow/providers/google/common/hooks/base_google.py
Expand Up @@ -493,9 +493,6 @@ def provide_authorized_gcloud(self):
gcloud_config_tmp = exit_stack.enter_context(tempfile.TemporaryDirectory())
exit_stack.enter_context(patch_environ({CLOUD_SDK_CONFIG_DIR: gcloud_config_tmp}))

if project_id:
# Don't display stdout/stderr for security reason
check_output(["gcloud", "config", "set", "core/project", project_id])
if CREDENTIALS in os.environ:
# This solves most cases when we are logged in using the service key in Airflow.
# Don't display stdout/stderr for security reason
Expand All @@ -507,6 +504,9 @@ def provide_authorized_gcloud(self):
f"--key-file={os.environ[CREDENTIALS]}",
]
)
if project_id:
# Don't display stdout/stderr for security reason
check_output(["gcloud", "config", "set", "core/project", project_id])
elif os.path.exists(credentials_path):
# If we are logged in by `gcloud auth application-default` then we need to log in manually.
# This will make the `gcloud auth application-default` and `gcloud auth` credentials equals.
Expand Down

0 comments on commit 2fadf3c

Please sign in to comment.