From 517257cbef9f60d9b0c1151753e6519a9d10099c Mon Sep 17 00:00:00 2001 From: Srdjan Lulic Date: Thu, 15 May 2025 17:08:38 +0100 Subject: [PATCH] Fix flaky availability checks in docker-tests by using exponential backoff in the retry mechanism (#3499) --- .../tests/check_availability.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/opentelemetry-docker-tests/tests/check_availability.py b/tests/opentelemetry-docker-tests/tests/check_availability.py index 4eed135e5..70268a0c0 100644 --- a/tests/opentelemetry-docker-tests/tests/check_availability.py +++ b/tests/opentelemetry-docker-tests/tests/check_availability.py @@ -42,8 +42,8 @@ MSSQL_HOST = os.getenv("MSSQL_HOST", "localhost") MSSQL_PORT = int(os.getenv("MSSQL_PORT", "1433")) MSSQL_USER = os.getenv("MSSQL_USER", "sa") MSSQL_PASSWORD = os.getenv("MSSQL_PASSWORD", "yourStrong(!)Password") -RETRY_COUNT = 8 -RETRY_INTERVAL = 5 # Seconds +RETRY_COUNT = 5 +RETRY_INITIAL_INTERVAL = 2 # Seconds logger = logging.getLogger(__name__) @@ -56,6 +56,8 @@ def retryable(func): func() return except Exception as ex: # pylint: disable=broad-except + # Exponential backoff + backoff_interval = RETRY_INITIAL_INTERVAL * (2**i) logger.error( "waiting for %s, retry %d/%d [%s]", func.__name__, @@ -63,7 +65,7 @@ def retryable(func): RETRY_COUNT, ex, ) - time.sleep(RETRY_INTERVAL) + time.sleep(backoff_interval) raise Exception(f"waiting for {func.__name__} failed") return wrapper