Tim Andersson has proposed merging ~andersson123/autopkgtest-cloud:improve-handling-cache-amqp-failures 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/458799 -- Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~andersson123/autopkgtest-cloud:improve-handling-cache-amqp-failures into autopkgtest-cloud:master.
diff --git a/charms/focal/autopkgtest-web/webcontrol/request/submit.py b/charms/focal/autopkgtest-web/webcontrol/request/submit.py index 1110863..bbee072 100644 --- a/charms/focal/autopkgtest-web/webcontrol/request/submit.py +++ b/charms/focal/autopkgtest-web/webcontrol/request/submit.py @@ -12,6 +12,7 @@ import re import sqlite3 import urllib.parse import urllib.request +import signal from datetime import datetime from urllib.error import HTTPError @@ -76,6 +77,9 @@ class Submit: self.architectures.add(row[0]) logging.debug("Valid architectures: %s" % self.architectures) + signal.signal(signal.SIGALRM, self.send_amqp_request_hander) + signal.alarm(60) + # dissect AMQP URL self.amqp_creds = urllib.parse.urlsplit( cp["amqp"]["uri"], allow_fragments=False @@ -343,10 +347,16 @@ class Submit: password=self.amqp_creds.password, ) as amqp_con: with amqp_con.channel() as ch: - ch.basic_publish( - amqp.Message(body, delivery_mode=2), # persistent - routing_key=queue, - ) + try: + ch.basic_publish( + amqp.Message(body, delivery_mode=2), # persistent + routing_key=queue, + ) + except amqp.exceptions.AMQPException as _: + raise Exception("Publishing message to amqp failed.") + + def send_amqp_request_hander(signum, frame): + raise Exception("Publishing message to amqp failed.") @classmethod def post_json(cls, url, data, auth_file, project):
-- Mailing list: https://launchpad.net/~canonical-ubuntu-qa Post to : canonical-ubuntu-qa@lists.launchpad.net Unsubscribe : https://launchpad.net/~canonical-ubuntu-qa More help : https://help.launchpad.net/ListHelp