Tim Andersson has proposed merging ~andersson123/autopkgtest-cloud:ugj-fix 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/477729
-- 
Your team Canonical's Ubuntu QA is requested to review the proposed merge of 
~andersson123/autopkgtest-cloud:ugj-fix into autopkgtest-cloud:master.
diff --git a/charms/focal/autopkgtest-web/webcontrol/update-github-jobs b/charms/focal/autopkgtest-web/webcontrol/update-github-jobs
index a90a75e..5cb77d0 100755
--- a/charms/focal/autopkgtest-web/webcontrol/update-github-jobs
+++ b/charms/focal/autopkgtest-web/webcontrol/update-github-jobs
@@ -1,5 +1,6 @@
 #!/usr/bin/python3
 
+import gzip
 import io
 import json
 import logging
@@ -24,6 +25,24 @@ swift_container_cache = None
 result_cache = {}
 
 
+def logfile_confirms_job(swift_conn, container, logfile_obj, params):
+    _, contents = swift_conn.get_object(container, logfile_obj)
+    logfile = gzip.decompress(contents)
+    logfile_lines = logfile.splitlines()
+    logfile_iter = iter(logfile_lines)
+    command_line = None
+    while not command_line:
+        line = next(logfile_iter)
+        if "command line: " in line:
+            command_line = line
+
+    env = params["env"]
+    for key_equals_value in env:
+        if key_equals_value not in command_line:
+            return False
+    return True
+
+
 def result_matches_job(swift_conn, container, result_obj, params):
     global result_cache
 
@@ -51,7 +70,19 @@ def result_matches_job(swift_conn, container, result_obj, params):
             result_cache[result_obj] = (exitcode, info)
         except (KeyError, ValueError, tarfile.TarError) as e:
             logging.error("broken result %s: %s", result_obj, e)
-            return
+            logging.warning(
+                "Proceeding to check job via logfile rather than result.tar..."
+            )
+            return (
+                1
+                if logfile_confirms_job(
+                    swift_conn,
+                    container,
+                    result_obj.replace("result.tar", "log.gz"),
+                    params,
+                )
+                else None
+            )
     else:
         exitcode, info = result_cache[result_obj]
 
-- 
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

Reply via email to