Double Bitwarden call timeout for each retry (#896)

This commit is contained in:
Kerem Yilmaz
2024-10-02 11:05:29 -07:00
committed by GitHub
parent c5399e73a1
commit 44627df9da

View File

@@ -82,13 +82,14 @@ class BitwardenService:
url: str,
collection_id: str | None = None,
remaining_retries: int = settings.BITWARDEN_MAX_RETRIES,
timeout: int = settings.BITWARDEN_TIMEOUT_SECONDS,
fail_reasons: list[str] = [],
) -> dict[str, str]:
"""
Get the secret value from the Bitwarden CLI.
"""
try:
async with asyncio.timeout(settings.BITWARDEN_TIMEOUT_SECONDS):
async with asyncio.timeout(timeout):
return await BitwardenService._get_secret_value_from_url(
client_id=client_id,
client_secret=client_secret,
@@ -111,6 +112,8 @@ class BitwardenService:
url=url,
collection_id=collection_id,
remaining_retries=remaining_retries,
# Double the timeout for the next retry
timeout=timeout * 2,
fail_reasons=fail_reasons + [f"{type(e).__name__}: {str(e)}"],
)
@@ -207,13 +210,14 @@ class BitwardenService:
identity_key: str,
identity_fields: list[str],
remaining_retries: int = settings.BITWARDEN_MAX_RETRIES,
timeout: int = settings.BITWARDEN_TIMEOUT_SECONDS,
fail_reasons: list[str] = [],
) -> dict[str, str]:
"""
Get the secret value from the Bitwarden CLI.
"""
try:
async with asyncio.timeout(settings.BITWARDEN_TIMEOUT_SECONDS):
async with asyncio.timeout(timeout):
return await BitwardenService._get_sensitive_information_from_identity(
client_id=client_id,
client_secret=client_secret,
@@ -238,6 +242,8 @@ class BitwardenService:
identity_key=identity_key,
identity_fields=identity_fields,
remaining_retries=remaining_retries,
# Double the timeout for the next retry
timeout=timeout * 2,
fail_reasons=fail_reasons + [f"{type(e).__name__}: {str(e)}"],
)