Tim Andersson has proposed merging ~andersson123/autopkgtest-cloud:investigate_debvm_looping 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/446179 -- Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~andersson123/autopkgtest-cloud:investigate_debvm_looping into autopkgtest-cloud:master.
diff --git a/.pylintrc b/.pylintrc index b6b77fa..7581e1b 100644 --- a/.pylintrc +++ b/.pylintrc @@ -40,6 +40,7 @@ reports=no score=no [TYPECHECK] +generated-members=app.logger ignored-modules= amulet, diff --git a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker index 2af9dc1..d2eb849 100755 --- a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker +++ b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker @@ -71,7 +71,7 @@ big_packages = set() long_tests = set() never_run = set() -FAIL_CODES = (4, 6, 12, 14, 20) +FAIL_CODES = (4, 6, 12, 14, 20, 127) # In the case of a tmpfail, look for these strings in the log and if they're # found, consider this a real failure instead. This is useful if the test diff --git a/charms/focal/autopkgtest-web/webcontrol/helpers/utils.py b/charms/focal/autopkgtest-web/webcontrol/helpers/utils.py index 6fbb09c..0bdc286 100644 --- a/charms/focal/autopkgtest-web/webcontrol/helpers/utils.py +++ b/charms/focal/autopkgtest-web/webcontrol/helpers/utils.py @@ -5,6 +5,18 @@ utilities for autopkgtest-web webcontrol import logging import os import sqlite3 +from logging.handlers import RotatingFileHandler + + +def get_handler(): + format = "%(asctime)s : %(levelname)s : %(name)s : %(message)s" + # Needs /tmp/ for some reason + handler = RotatingFileHandler( + "/tmp/webcontrol.log", maxBytes=5000, backupCount=3 + ) + handler.setFormatter(logging.Formatter(format)) + handler.setLevel(logging.INFO) + return handler def setup_key(app, path): diff --git a/charms/focal/autopkgtest-web/webcontrol/private-results.cgi b/charms/focal/autopkgtest-web/webcontrol/private-results.cgi index 9aa5a12..56df15e 100755 --- a/charms/focal/autopkgtest-web/webcontrol/private-results.cgi +++ b/charms/focal/autopkgtest-web/webcontrol/private-results.cgi @@ -4,8 +4,11 @@ from wsgiref.handlers import CGIHandler +from helpers.utils import get_handler from private_results.app import app +app.logger.addHandler(get_handler()) + if __name__ == "__main__": app.config["DEBUG"] = True CGIHandler().run(app) diff --git a/charms/focal/autopkgtest-web/webcontrol/private_results/app.py b/charms/focal/autopkgtest-web/webcontrol/private_results/app.py index 9ae1e89..0161a03 100644 --- a/charms/focal/autopkgtest-web/webcontrol/private_results/app.py +++ b/charms/focal/autopkgtest-web/webcontrol/private_results/app.py @@ -84,6 +84,7 @@ PATH = os.path.join(os.getenv("TMPDIR", "/tmp"), "autopkgtest_webcontrol") os.makedirs(PATH, exist_ok=True) app = Flask("private-results") app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1) +app.logger.setLevel(logging.INFO) # Keep secret persistent between CGI invocations secret_path = os.path.join(PATH, "secret_key") setup_key(app, secret_path) diff --git a/charms/focal/autopkgtest-web/webcontrol/request.cgi b/charms/focal/autopkgtest-web/webcontrol/request.cgi index 8dcf2b5..4dd67a6 100755 --- a/charms/focal/autopkgtest-web/webcontrol/request.cgi +++ b/charms/focal/autopkgtest-web/webcontrol/request.cgi @@ -4,8 +4,11 @@ from wsgiref.handlers import CGIHandler +from helpers.utils import get_handler from request.app import app +app.logger.addHandler(get_handler()) + if __name__ == "__main__": app.config["DEBUG"] = True CGIHandler().run(app) diff --git a/charms/focal/autopkgtest-web/webcontrol/request/app.py b/charms/focal/autopkgtest-web/webcontrol/request/app.py index 8654ec2..e0e7c48 100644 --- a/charms/focal/autopkgtest-web/webcontrol/request/app.py +++ b/charms/focal/autopkgtest-web/webcontrol/request/app.py @@ -107,6 +107,7 @@ PATH = os.path.join(os.path.sep, "run", "autopkgtest_webcontrol") os.makedirs(PATH, exist_ok=True) app = Flask("request") app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1) +app.logger.setLevel(logging.INFO) # keep secret persistent between CGI invocations secret_path = os.path.join(PATH, "secret_key") setup_key(app, secret_path) diff --git a/charms/focal/autopkgtest-web/webcontrol/request/submit.py b/charms/focal/autopkgtest-web/webcontrol/request/submit.py index ec97969..34068a2 100644 --- a/charms/focal/autopkgtest-web/webcontrol/request/submit.py +++ b/charms/focal/autopkgtest-web/webcontrol/request/submit.py @@ -18,6 +18,9 @@ from urllib.error import HTTPError import amqplib.client_0_8 as amqp from distro_info import UbuntuDistroInfo +# Creates a sublogger from ../requests/app.py +logger = logging.getLogger("request.submit") + # Launchpad REST API base LP = "https://api.launchpad.net/1.0/" NAME = re.compile("^[a-z0-9][a-z0-9.+-]+$") @@ -44,7 +47,7 @@ class Submit: self.releases = set( UbuntuDistroInfo().supported() + UbuntuDistroInfo().supported_esm() ) - logging.debug("Valid releases: %s" % self.releases) + logger.debug("Valid releases: %s" % self.releases) self.architectures = set() c = self.db_con.cursor() @@ -54,14 +57,14 @@ class Submit: if row is None: break self.architectures.add(row[0]) - logging.debug("Valid architectures: %s" % self.architectures) + logger.debug("Valid architectures: %s" % self.architectures) # dissect AMQP URL self.amqp_creds = urllib.parse.urlsplit( cp["amqp"]["uri"], allow_fragments=False ) assert self.amqp_creds.scheme == "amqp" - logging.debug("AMQP credentials: %s" % repr(self.amqp_creds)) + logger.debug("AMQP credentials: %s" % repr(self.amqp_creds)) # pylint: disable=dangerous-default-value def validate_distro_request( @@ -326,7 +329,7 @@ class Submit: credentials = l.split(":", 1)[1].strip() break else: - logging.error( + logger.error( "%s does not have password for project %s", auth_file, project ) return @@ -342,7 +345,7 @@ class Submit: }, ) with urllib.request.urlopen(req) as f: - logging.debug( + logger.debug( "POST to URL %s succeeded with code %u: %s", f.geturl(), f.getcode(), @@ -367,7 +370,7 @@ class Submit: "name": json.dumps(name), }, ) - logging.debug( + logger.debug( "is_valid_ppa(%s): code %u, response %s", ppa, code, repr(response) ) if code < 200 or code >= 300: @@ -422,7 +425,7 @@ class Submit: (code, response) = self.lp_request(obj, req) if code < 200 or code >= 300: return None - logging.debug( + logger.debug( "is_valid_package_version(%s, %s, %s): code %u, response %s", release, package, @@ -450,7 +453,7 @@ class Submit: "sourcepackagename": json.dumps(package), }, ) - logging.debug( + logger.debug( "can_upload(%s, %s, %s, %s): (%u, %s)", person, release, @@ -486,13 +489,13 @@ class Submit: with urllib.request.urlopen(url, timeout=10) as req: code = req.getcode() if code >= 300: - logging.error( + logger.error( "URL %s failed with code %u", req.geturl(), code ) return (code, None) response = req.read() except HTTPError as e: - logging.error( + logger.error( "%s failed with %u: %s\n%s", url, e.code, e.reason, e.headers ) return (e.code, None) @@ -500,12 +503,12 @@ class Submit: try: response = json.loads(response.decode("UTF-8")) except (UnicodeDecodeError, ValueError) as e: - logging.error( + logger.error( "URL %s gave invalid response %s: %s", req.geturl(), response, str(e), ) return (500, None) - logging.debug("lp_request %s succeeded: %s", url, response) + logger.debug("lp_request %s succeeded: %s", url, response) return (code, response)
-- 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