From 06e8f598bab8402b6fc9f14513738c4cd567e90e Mon Sep 17 00:00:00 2001 From: Iain Lane Date: Mon, 21 Jan 2019 11:20:27 +0000 Subject: [PATCH] Repair requests without testpkg-version We're supposed to synthesise an "unknown" version for these, but a bug in the worker meant we didn't do that in some cases and these leaked into swift. Let's repair it client-side. --- britney2/policies/autopkgtest.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/britney2/policies/autopkgtest.py b/britney2/policies/autopkgtest.py index 43fed24..e248208 100644 --- a/britney2/policies/autopkgtest.py +++ b/britney2/policies/autopkgtest.py @@ -852,7 +852,19 @@ class AutopkgtestPolicy(BasePolicy): try: with tarfile.open(None, 'r', tar_bytes) as tar: exitcode = int(tar.extractfile('exitcode').read().strip()) - srcver = tar.extractfile('testpkg-version').read().decode().strip() + try: + srcver = tar.extractfile('testpkg-version').read().decode().strip() + except KeyError as e: + # We have some buggy results in Ubuntu's swift that break a + # full reimport. Sometimes we fake up the exit code (when + # we want to convert tmpfails to permanent fails), but an + # early bug meant we sometimes didn't include a + # testpkg-version. + if exitcode in (4, 12, 20): + # repair it + srcver = "%s unknown" % (src) + else: + raise (ressrc, ver) = srcver.split() testinfo = json.loads(tar.extractfile('testinfo.json').read().decode()) except (KeyError, ValueError, tarfile.TarError) as e: