diff options
author | Guillaume Tucker <guillaume.tucker@collabora.com> | 2018-12-11 19:53:51 +0000 |
---|---|---|
committer | Guillaume Tucker <guillaume.tucker@collabora.com> | 2018-12-14 15:46:11 +0000 |
commit | 93e941ea0211cc5cbdc9bdf7cf71cf2a99a33da9 (patch) | |
tree | 9f2e4a952931d0f8047a2949acea67effedef570 /lava-v2-callback.py | |
parent | c79ca0f9ad220c5f4bc8b90307ed6a43f692ba6c (diff) |
lava-v2-callback.py: handle infrastructure errors
Add is_infra_error() function to first check whether the LAVA job
failed due to an infrastructure error, in which case return
BISECT_SKIP. Otherwise, call handle_boot() function to handle the
actual boot result.
Signed-off-by: Guillaume Tucker <guillaume.tucker@collabora.com>
Diffstat (limited to 'lava-v2-callback.py')
-rwxr-xr-x | lava-v2-callback.py | 56 |
1 files changed, 40 insertions, 16 deletions
diff --git a/lava-v2-callback.py b/lava-v2-callback.py index 91ef27d..3e4e0c0 100755 --- a/lava-v2-callback.py +++ b/lava-v2-callback.py @@ -20,6 +20,7 @@ import argparse import json import sys +import yaml # copied from lava-server/lava_scheduler_app/models.py SUBMITTED = 0 @@ -29,6 +30,39 @@ INCOMPLETE = 3 CANCELED = 4 CANCELING = 5 +# git bisect return codes +BISECT_PASS = 0 +BISECT_SKIP = 1 +BISECT_FAIL = 2 + +# LAVA job result names +LAVA_JOB_RESULT_NAMES = { + COMPLETE: "PASS", + INCOMPLETE: "FAIL", + CANCELED: "UNKNOWN", + CANCELING: "UNKNOWN", +} + +# git bisect and LAVA job status map +BOOT_STATUS_MAP = { + COMPLETE: BISECT_PASS, + INCOMPLETE: BISECT_FAIL, +} + + +def is_infra_error(cb): + lava_yaml = cb['results']['lava'] + lava = yaml.load(lava_yaml) + stages = {s['name']: s for s in lava} + job_meta = stages['job']['metadata'] + return job_meta.get('error_type') == "Infrastructure" + + +def handle_boot(cb): + job_status = cb['status'] + print("Status: {}".format(LAVA_JOB_RESULT_NAMES[job_status])) + return BOOT_STATUS_MAP.get(job_status, BISECT_SKIP) + def main(args): with open(args.json) as json_file: @@ -38,23 +72,13 @@ def main(args): print("Token mismatch") sys.exit(1) - job_status = cb['status'] - - lava_job_result = { - COMPLETE: "PASS", - INCOMPLETE: "FAIL", - CANCELED: "UNKNOWN", - CANCELING: "UNKNOWN", - } - - print("Status: {}".format(lava_job_result[job_status])) - - status_map = { - COMPLETE: 0, - INCOMPLETE: 2, - } + if is_infra_error(cb): + print("Infrastructure error") + ret = BISECT_SKIP + else: + ret = handle_boot(cb) - sys.exit(status_map.get(job_status, 1)) + sys.exit(ret) if __name__ == '__main__': |