Merge ~twom/launchpad:reraise-after-failed-retry into launchpad:master

Proposed by Tom Wardill
Status: Merged
Approved by: Tom Wardill
Approved revision: 8f7b89e9a829e62797e1d091228d1d72c3ddb781
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~twom/launchpad:reraise-after-failed-retry
Merge into: launchpad:master
Diff against target: 37 lines (+9/-6)
2 files modified
lib/lp/oci/model/ociregistryclient.py (+1/-0)
lib/lp/oci/tests/test_ociregistryclient.py (+8/-6)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+403818@code.launchpad.net

Commit message

Reraise the original error on a failed retry

Description of the change

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.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/oci/model/ociregistryclient.py b/lib/lp/oci/model/ociregistryclient.py
2index dbed50c..98b925e 100644
3--- a/lib/lp/oci/model/ociregistryclient.py
4+++ b/lib/lp/oci/model/ociregistryclient.py
5@@ -102,6 +102,7 @@ class OCIRegistryClient:
6 @retry(
7 wait=wait_fixed(3),
8 before=before_log(log, logging.INFO),
9+ reraise=True,
10 retry=retry_if_exception_type(ConnectionError),
11 stop=stop_after_attempt(5))
12 def _upload(cls, digest, push_rule, fileobj, length, http_client):
13diff --git a/lib/lp/oci/tests/test_ociregistryclient.py b/lib/lp/oci/tests/test_ociregistryclient.py
14index 2fa179e..286bdce 100644
15--- a/lib/lp/oci/tests/test_ociregistryclient.py
16+++ b/lib/lp/oci/tests/test_ociregistryclient.py
17@@ -535,12 +535,14 @@ class TestOCIRegistryClient(OCIConfigHelperMixin, SpyProxyCallsMixin,
18 self.client._upload(
19 "test-digest", push_rule,
20 None, 0, RegistryHTTPClient(push_rule))
21- except RetryError:
22- pass
23- # Check that tenacity and our counting agree
24- self.assertEqual(
25- 5, self.client._upload.retry.statistics["attempt_number"])
26- self.assertEqual(5, self.retry_count)
27+ except ConnectionError:
28+ # Check that tenacity and our counting agree
29+ self.assertEqual(
30+ 5, self.client._upload.retry.statistics["attempt_number"])
31+ self.assertEqual(5, self.retry_count)
32+ except Exception:
33+ # We should see the original exception, not a RetryError
34+ raise
35
36 @responses.activate
37 def test_upload_put_blob_raises_error(self):

Subscribers

People subscribed via source and target branches

to status/vote changes: