← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:snap-charm-retry-504 into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:snap-charm-retry-504 into launchpad:master.

Commit message:
Automatically retry 504 errors from the snap store or Charmhub

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/408116

"Gateway Timeout" seems like a reasonable sort of thing to retry automatically, at least for a while.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:snap-charm-retry-504 into launchpad:master.
diff --git a/lib/lp/charms/model/charmhubclient.py b/lib/lp/charms/model/charmhubclient.py
index 6de887c..a376097 100644
--- a/lib/lp/charms/model/charmhubclient.py
+++ b/lib/lp/charms/model/charmhubclient.py
@@ -82,7 +82,7 @@ class CharmhubClient:
                         error["message"]
                         for error in response_data["error-list"])
         detail = requests_error.response.content.decode(errors="replace")
-        can_retry = requests_error.response.status_code in (502, 503)
+        can_retry = requests_error.response.status_code in (502, 503, 504)
         return error_class(error_message, detail=detail, can_retry=can_retry)
 
     @classmethod
diff --git a/lib/lp/snappy/model/snapstoreclient.py b/lib/lp/snappy/model/snapstoreclient.py
index fd0415b..3d1e65d 100644
--- a/lib/lp/snappy/model/snapstoreclient.py
+++ b/lib/lp/snappy/model/snapstoreclient.py
@@ -208,7 +208,7 @@ class SnapStoreClient:
                         for error in response_data["error_list"])
         detail = six.ensure_text(
             requests_error.response.content, errors="replace")
-        can_retry = requests_error.response.status_code in (502, 503)
+        can_retry = requests_error.response.status_code in (502, 503, 504)
         return error_class(error_message, detail=detail, can_retry=can_retry)
 
     @classmethod