Skip to content

Commit 9cea321

Browse files
Cache credentials (#4446)
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.
1 parent 933a999 commit 9cea321

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/clusterfuzz/_internal/google_cloud_utils/credentials.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from google.auth.transport import requests
2020
from google.oauth2 import service_account
2121

22+
from clusterfuzz._internal.base import memoize
2223
from clusterfuzz._internal.base import retry
2324
from clusterfuzz._internal.base import utils
2425
from clusterfuzz._internal.google_cloud_utils import secret_manager
@@ -59,6 +60,7 @@ def _use_anonymous_credentials():
5960
retries=FAIL_RETRIES,
6061
delay=FAIL_WAIT,
6162
function='google_cloud_utils.credentials.get_default')
63+
@memoize.wrap(memoize.FifoInMemory(1))
6264
def get_default(scopes=None):
6365
"""Get default Google Cloud credentials."""
6466
if _use_anonymous_credentials():

0 commit comments

Comments
 (0)