← Back to team overview

canonical-ubuntu-qa team mailing list archive

[Merge] ~andersson123/autopkgtest-cloud:cache-amqp-hotfix into autopkgtest-cloud:master

 

Tim Andersson has proposed merging ~andersson123/autopkgtest-cloud:cache-amqp-hotfix into autopkgtest-cloud:master.

Requested reviews:
  Canonical's Ubuntu QA (canonical-ubuntu-qa)

For more details, see:
https://code.launchpad.net/~andersson123/autopkgtest-cloud/+git/autopkgtest-cloud/+merge/457046
-- 
Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~andersson123/autopkgtest-cloud:cache-amqp-hotfix into autopkgtest-cloud:master.
diff --git a/charms/focal/autopkgtest-web/webcontrol/cache-amqp b/charms/focal/autopkgtest-web/webcontrol/cache-amqp
index 33eb496..7155ec2 100755
--- a/charms/focal/autopkgtest-web/webcontrol/cache-amqp
+++ b/charms/focal/autopkgtest-web/webcontrol/cache-amqp
@@ -291,11 +291,18 @@ if __name__ == "__main__":
             with open(args.output, "r") as f:
                 queued_local = json.load(f)
         for srvname_cookie in cookies.split(" "):
-            req = urllib.request.Request(webpage + "/queues.json")
-            req.add_header("Cookie", "SRVNAME=" + srvname_cookie)
-            queue_contents = json.loads(urllib.request.urlopen(req).read())
-            if queue_contents != queued_local:
-                break
+            try:
+                req = urllib.request.Request(webpage + "/queues.json")
+                req.add_header("Cookie", "SRVNAME=" + srvname_cookie)
+                queue_contents = json.loads(urllib.request.urlopen(req).read())
+                if queue_contents != queued_local:
+                    # we break the loop as we need to write queues.json
+                    break
+            except urllib.error.HTTPError as _:
+                # Internal server error means we're requesting queues.json
+                # from the web worker this is currently being run on, so
+                # we go to next loop iteration to try other cookie
+                continue
 
     with tempfile.NamedTemporaryFile(
         mode="w", dir=os.path.dirname(args.output), delete=False