From 9cea3212cbcafee6a4adb02f96ca16ebb1009f86 Mon Sep 17 00:00:00 2001 From: jonathanmetzman <31354670+jonathanmetzman@users.noreply.github.com> Date: Tue, 26 Nov 2024 13:38:15 -0500 Subject: [PATCH] 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. --- src/clusterfuzz/_internal/google_cloud_utils/credentials.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/clusterfuzz/_internal/google_cloud_utils/credentials.py b/src/clusterfuzz/_internal/google_cloud_utils/credentials.py index bcee8e05e5..aa1deffde4 100644 --- a/src/clusterfuzz/_internal/google_cloud_utils/credentials.py +++ b/src/clusterfuzz/_internal/google_cloud_utils/credentials.py @@ -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 @@ -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():