From 79c0a53c084cd8f75e4f78c1e9785091f059416b Mon Sep 17 00:00:00 2001 From: bloodearnest Date: Wed, 19 Oct 2022 18:56:41 +0100 Subject: [PATCH] fix: make DEPENDENCY_FAILED spans with the error state --- jobrunner/run.py | 9 +++++---- tests/test_run.py | 2 ++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/jobrunner/run.py b/jobrunner/run.py index 40f508b3..119c53f0 100644 --- a/jobrunner/run.py +++ b/jobrunner/run.py @@ -133,7 +133,7 @@ def handle_single_job(job, api): "for users to fix.\n" "The tech team are automatically notified of these errors and will be " "investigating.", - exc=exc, + error=exc, ) # Do not clean up, as we may want to debug # @@ -222,6 +222,7 @@ def handle_job(job, api, mode=None, paused=None): job, StatusCode.DEPENDENCY_FAILED, "Not starting as dependency failed", + error=True, ) return @@ -455,11 +456,11 @@ def get_states_of_awaited_jobs(job): return states -def mark_job_as_failed(job, code, message=None, exc=None, **attrs): +def mark_job_as_failed(job, code, message=None, error=None, **attrs): if message is None: - message = f"{type(exc).__name__}: {exc}" + message = str(error) - set_state(job, State.FAILED, code, message, error=exc, attrs=attrs) + set_state(job, State.FAILED, code, message, error=error, attrs=attrs) def set_state(job, state, code, message, error=None, **attrs): diff --git a/tests/test_run.py b/tests/test_run.py index e246f055..28930d64 100644 --- a/tests/test_run.py +++ b/tests/test_run.py @@ -118,7 +118,9 @@ def test_handle_job_pending_dependency_failed(db): spans = get_trace() assert spans[-3].name == "CREATED" assert spans[-2].name == "DEPENDENCY_FAILED" + assert spans[-2].status.status_code == trace.StatusCode.ERROR assert spans[-1].name == "JOB" + assert spans[-1].status.status_code == trace.StatusCode.ERROR def test_handle_pending_job_waiting_on_dependency(db):