Tim Andersson has proposed merging ~andersson123/autopkgtest-cloud:filter-amqp-no-need-rerun 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/459653 -- Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~andersson123/autopkgtest-cloud:filter-amqp-no-need-rerun into autopkgtest-cloud:master.
diff --git a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/filter-amqp b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/filter-amqp index 2aba358..758e7b5 100755 --- a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/filter-amqp +++ b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/tools/filter-amqp @@ -1,6 +1,8 @@ #!/usr/bin/python3 # Filter out AMQP requests that match a given regex +import datetime +import time import logging import optparse # pylint: disable=deprecated-module import re @@ -8,6 +10,8 @@ import urllib.parse import amqplib.client_0_8 as amqp +FILTER_CHECK_SECONDS = 59 + def filter_amqp(options, host, queue_name, regex): url_parts = urllib.parse.urlsplit(host, allow_fragments=False) @@ -18,6 +22,7 @@ def filter_amqp(options, host, queue_name, regex): password=url_parts.password, ) ch = amqp_con.channel() + now = datetime.datetime.now() while True: r = ch.basic_get(queue_name) @@ -28,12 +33,21 @@ def filter_amqp(options, host, queue_name, regex): else: body = r.body logging.debug("queue item: %s (not deleting)", body) - if filter_re.search(body): + last_search_successful = filter_re.search(body) + if last_search_successful: if options.dry_run: logging.info("queue item: %s (would delete)", body) else: logging.info("queue item: %s (deleting)", body) ch.basic_ack(r.delivery_tag) + else: + now_check = datetime.datetime.now() + if not last_search_successful and ( + (now_check - now) + > datetime.timedelta(seconds=FILTER_CHECK_SECONDS) + ): + break + now = now_check if last_search_successful else now def main():
-- 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