Skip to content

Commit

Permalink
Cache credentials (#4446)
Browse files Browse the repository at this point in the history
Getting credentials is pretty slow since it launches a gcloud process.
We should just cache credentials. Supposedly the library itself handles
refreshes. We are also caching in storage.py so there's proof it's safe.
  • Loading branch information
jonathanmetzman authored Nov 26, 2024
1 parent 933a999 commit 9cea321
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/clusterfuzz/_internal/google_cloud_utils/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from google.auth.transport import requests
from google.oauth2 import service_account

from clusterfuzz._internal.base import memoize
from clusterfuzz._internal.base import retry
from clusterfuzz._internal.base import utils
from clusterfuzz._internal.google_cloud_utils import secret_manager
Expand Down Expand Up @@ -59,6 +60,7 @@ def _use_anonymous_credentials():
retries=FAIL_RETRIES,
delay=FAIL_WAIT,
function='google_cloud_utils.credentials.get_default')
@memoize.wrap(memoize.FifoInMemory(1))
def get_default(scopes=None):
"""Get default Google Cloud credentials."""
if _use_anonymous_credentials():
Expand Down

0 comments on commit 9cea321

Please sign in to comment.