From fc75af35d41df6c7742caef751428aa875199990 Mon Sep 17 00:00:00 2001 From: Gavin Mak Date: Tue, 20 Jun 2023 20:06:27 +0000 Subject: [PATCH] Bump Gerrit fetch retry logic to 6 tries and 12s initial sleep Upon Gerrit team's suggestion, up the retry time and number of retries to handle increased replication delay. Bug:b/285164390 Change-Id: If833ae9bb0f8c276b761970a8b5f96ec217d11b9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4621268 Commit-Queue: Josip Sokcevic Reviewed-by: Josip Sokcevic Auto-Submit: Gavin Mak --- gerrit_util.py | 9 +++++---- tests/gerrit_util_test.py | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/gerrit_util.py b/gerrit_util.py index 2ccc68556..8312bbac7 100644 --- a/gerrit_util.py +++ b/gerrit_util.py @@ -44,10 +44,11 @@ else: from io import StringIO LOGGER = logging.getLogger() -# With a starting sleep time of 10.0 seconds, x <= [1.8-2.2]x backoff, and five -# total tries, the sleep time between the first and last tries will be ~7 min. -TRY_LIMIT = 5 -SLEEP_TIME = 10.0 +# With a starting sleep time of 12.0 seconds, x <= [1.8-2.2]x backoff, and six +# total tries, the sleep time between the first and last tries will be ~6 min +# (excluding time for each try). +TRY_LIMIT = 6 +SLEEP_TIME = 12.0 MAX_BACKOFF = 2.2 MIN_BACKOFF = 1.8 diff --git a/tests/gerrit_util_test.py b/tests/gerrit_util_test.py index 76ab745a6..4eda84aa8 100755 --- a/tests/gerrit_util_test.py +++ b/tests/gerrit_util_test.py @@ -390,7 +390,7 @@ class GerritUtilTest(unittest.TestCase): self.assertEqual('content✔', gerrit_util.ReadHttpResponse(conn).getvalue()) self.assertEqual(2, len(conn.request.mock_calls)) - gerrit_util.time_sleep.assert_called_once_with(10.0) + gerrit_util.time_sleep.assert_called_once_with(12.0) def testReadHttpResponse_TimeoutAndSuccess(self): conn = mock.Mock(req_params={'uri': 'uri', 'method': 'method'}) @@ -401,7 +401,7 @@ class GerritUtilTest(unittest.TestCase): self.assertEqual('content✔', gerrit_util.ReadHttpResponse(conn).getvalue()) self.assertEqual(2, len(conn.request.mock_calls)) - gerrit_util.time_sleep.assert_called_once_with(10.0) + gerrit_util.time_sleep.assert_called_once_with(12.0) def testReadHttpResponse_Expected404(self): conn = mock.Mock()