Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 517257c

Browse files
authoredMay 15, 2025··
Fix flaky availability checks in docker-tests by using exponential backoff in the retry mechanism (#3499)
1 parent 4a1e0ce commit 517257c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed
 

‎tests/opentelemetry-docker-tests/tests/check_availability.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
MSSQL_PORT = int(os.getenv("MSSQL_PORT", "1433"))
4343
MSSQL_USER = os.getenv("MSSQL_USER", "sa")
4444
MSSQL_PASSWORD = os.getenv("MSSQL_PASSWORD", "yourStrong(!)Password")
45-
RETRY_COUNT = 8
46-
RETRY_INTERVAL = 5 # Seconds
45+
RETRY_COUNT = 5
46+
RETRY_INITIAL_INTERVAL = 2 # Seconds
4747

4848
logger = logging.getLogger(__name__)
4949

@@ -56,14 +56,16 @@ def wrapper():
5656
func()
5757
return
5858
except Exception as ex: # pylint: disable=broad-except
59+
# Exponential backoff
60+
backoff_interval = RETRY_INITIAL_INTERVAL * (2**i)
5961
logger.error(
6062
"waiting for %s, retry %d/%d [%s]",
6163
func.__name__,
6264
i + 1,
6365
RETRY_COUNT,
6466
ex,
6567
)
66-
time.sleep(RETRY_INTERVAL)
68+
time.sleep(backoff_interval)
6769
raise Exception(f"waiting for {func.__name__} failed")
6870

6971
return wrapper

0 commit comments

Comments
 (0)
Please sign in to comment.