Skip to content

Commit

Permalink
fixup! Release internally apache-airflow-providers-google 2022.5.18+c…
Browse files Browse the repository at this point in the history
…omposer

Cherry-pick change from the community: apache/airflow#23773

Change-Id: Icb16b28b969c38edf65bb826df65d79a0f170318
GitOrigin-RevId: c763dd5e76b110942bd787947b57a32ddcc81394
  • Loading branch information
Cloud Composer Team committed Jul 10, 2022
1 parent 8fb263f commit 6d9ca9c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion airflow/providers/google/cloud/utils/credentials_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
import google.auth
import google.auth.credentials
import google.oauth2.service_account
from google.auth import impersonated_credentials
from google.auth import compute_engine, impersonated_credentials
from google.auth.environment_vars import CREDENTIALS, LEGACY_PROJECT, PROJECT
from google.auth.exceptions import RefreshError
from google.auth.transport import _http_client

from airflow.exceptions import AirflowException
from airflow.providers.google.cloud._internal_client.secret_manager_client import _SecretManagerClient
Expand Down Expand Up @@ -248,6 +250,16 @@ def get_credentials_and_project(self) -> Tuple[google.auth.credentials.Credentia

project_id = _get_project_id_from_service_account_email(self.target_principal)

if isinstance(credentials, compute_engine.Credentials):
try:
credentials.refresh(_http_client.Request())
except RefreshError as msg:
"""
If the Compute Engine metadata service can't be reached in this case the instance has not
credentials.
"""
self._log_debug(msg)

return credentials, project_id

def _get_credentials_using_keyfile_dict(self):
Expand Down
Binary file modified dist/apache-airflow-providers-google-2022.5.18+composer.tar.gz
Binary file not shown.
Binary file not shown.

0 comments on commit 6d9ca9c

Please sign in to comment.