Skip to content

Fix handling of incomplete jobs failing before git checkout

Emanuele Aina requested to merge wip/em/fix-exception-incomplete-jobs into master

When available, we look for the checkout information to find the commit id for each testcase. However, if the job fails in the early stages, before being able to check anything out, then such information is not available, so we should handle gracefully the case instead of hitting an exception:

Exception on / [POST]
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/lib/python3/dist-packages/flask/app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/lib/python3/dist-packages/flask/app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python3/dist-packages/flask/_compat.py", line 35, in reraise
    raise value
  File "/usr/lib/python3/dist-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/lib/python3/dist-packages/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "./webhook.py", line 203, in post_results
    return process_job(job_data)
  File "./webhook.py", line 248, in process_job
    jobs.setdefault(job_id, TestJob(job_data)).update(job_data)
  File "/app/testobjects.py", line 216, in __init__
    self.update(rawdata)
  File "/app/testobjects.py", line 224, in update
    data = lava_jobdata_extract(rawdata)
  File "/app/testobjects.py", line 185, in lava_jobdata_extract
    jobdata.update(lava_jobdata_extract_results(data))
  File "/app/testobjects.py", line 150, in lava_jobdata_extract_results
    action, extra = actions[t['repository'], t['path']]
KeyError: ('https://gitlab.apertis.org/tests/apertis-test-cases.git', 'test-cases/sanity-check.yaml')

In turn, this exception causes jobs not being marked as completed, and thus we never manage to update Phabricator since the batch is stuck with pending jobs forever.

Merge request reports