Skip to content

Commit

Permalink
lava_callback.py: Handle failed jobs properly
Browse files Browse the repository at this point in the history
As mentioned in kernelci/kernelci-api#474,
even if job failed, node still registered as pass, and trying to
upload non-existing log file. Fix that, if job is not completed,
set node status to incomplete and do not upload log file.

Fixes: kernelci/kernelci-api#474

Depends on: kernelci/kernelci-core#2363

Signed-off-by: Denys Fedoryshchenko <[email protected]>
  • Loading branch information
nuclearcat committed Feb 12, 2024
1 parent ba21714 commit 8b50bf2
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/lava_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,20 @@ def async_job_submit(api_helper, node_id, job_callback):
# Or at least first record job_id in node metadata

log_parser = job_callback.get_log_parser()
storage_config_name = job_callback.get_meta('storage_config_name')
storage = _get_storage(storage_config_name)
log_txt_url = _upload_log(log_parser, job_node, storage)
job_node['artifacts']['lava_log'] = log_txt_url
hierarchy = job_callback.get_hierarchy(results, job_node)
api_helper.submit_results(hierarchy, job_node)
job_result = job_callback.get_job_status()
if job_result and job_result == 'pass':
storage_config_name = job_callback.get_meta('storage_config_name')
storage = _get_storage(storage_config_name)
log_txt_url = _upload_log(log_parser, job_node, storage)
job_node['artifacts']['lava_log'] = log_txt_url
hierarchy = job_callback.get_hierarchy(results, job_node)
api_helper.submit_results(hierarchy, job_node)
else:
# As in https://github.com/kernelci/kernelci-api/issues/474
# failed LAVA job should not upload empty log file and set result
# as 'pass'
job_node['result'] = job_result
api_helper.api.node.update(job_node)


@app.post('/node/<node_id>')
Expand Down

0 comments on commit 8b50bf2

Please sign in to comment.