← Back to team overview

canonical-ubuntu-qa team mailing list archive

[Merge] ~andersson123/autopkgtest-cloud:worker-nofail-jsondecodeerror into autopkgtest-cloud:master

 

Tim Andersson has proposed merging ~andersson123/autopkgtest-cloud:worker-nofail-jsondecodeerror 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/477319

worker noexit on JSONDecodeError - I think we may have been losing test results because of this. It'd certainly explain tests seemingly re-running in almost perpetuity
-- 
Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~andersson123/autopkgtest-cloud:worker-nofail-jsondecodeerror into autopkgtest-cloud:master.
diff --git a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker
index 99203fd..c281b0f 100755
--- a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker
+++ b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker
@@ -373,7 +373,14 @@ def process_output_dir(
     # dont_run for whatever reason, the file doesn't exist
     if os.path.isfile(os.path.join(dir, "testinfo.json")):
         with open(os.path.join(dir, "testinfo.json"), "r") as testinfo:
-            d = json.load(testinfo)
+            try:
+                d = json.load(testinfo)
+            except json.decoder.JSONDecodeError as json_err:
+                logging.warning(
+                    "Loading testinfo failed with: %s\nCreating empty testinfo",
+                    json_err,
+                )
+                d = {}
     d["uuid"] = test_uuid
     for key in KEYS_FOR_ADDITIONAL_PARAMS:
         d[key] = additional_params.get(key)