launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #27191
[Merge] ~twom/launchpad:reraise-after-failed-retry into launchpad:master
Tom Wardill has proposed merging ~twom/launchpad:reraise-after-failed-retry into launchpad:master.
Commit message:
Reraise the original error on a failed retry
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~twom/launchpad/+git/launchpad/+merge/403818
We are using tenacity to retry ConnectionErrors in OCI Registry Uploads.
By default if this fails all the retries, you get a RetryError raised.
Instead, lets raise the original ConnectionError as it'll give us more diagnostics.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~twom/launchpad:reraise-after-failed-retry into launchpad:master.
diff --git a/lib/lp/oci/model/ociregistryclient.py b/lib/lp/oci/model/ociregistryclient.py
index dbed50c..98b925e 100644
--- a/lib/lp/oci/model/ociregistryclient.py
+++ b/lib/lp/oci/model/ociregistryclient.py
@@ -102,6 +102,7 @@ class OCIRegistryClient:
@retry(
wait=wait_fixed(3),
before=before_log(log, logging.INFO),
+ reraise=True,
retry=retry_if_exception_type(ConnectionError),
stop=stop_after_attempt(5))
def _upload(cls, digest, push_rule, fileobj, length, http_client):
diff --git a/lib/lp/oci/tests/test_ociregistryclient.py b/lib/lp/oci/tests/test_ociregistryclient.py
index 2fa179e..286bdce 100644
--- a/lib/lp/oci/tests/test_ociregistryclient.py
+++ b/lib/lp/oci/tests/test_ociregistryclient.py
@@ -535,12 +535,14 @@ class TestOCIRegistryClient(OCIConfigHelperMixin, SpyProxyCallsMixin,
self.client._upload(
"test-digest", push_rule,
None, 0, RegistryHTTPClient(push_rule))
- except RetryError:
- pass
- # Check that tenacity and our counting agree
- self.assertEqual(
- 5, self.client._upload.retry.statistics["attempt_number"])
- self.assertEqual(5, self.retry_count)
+ except ConnectionError:
+ # Check that tenacity and our counting agree
+ self.assertEqual(
+ 5, self.client._upload.retry.statistics["attempt_number"])
+ self.assertEqual(5, self.retry_count)
+ except Exception:
+ # We should see the original exception, not a RetryError
+ raise
@responses.activate
def test_upload_put_blob_raises_error(self):