Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(job-runner): surface errors to Snuba admin #6704

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion snuba/admin/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,20 @@ def get_job_specs() -> Response:
@check_tool_perms(tools=[AdminTools.MANUAL_JOBS])
def execute_job(job_id: str) -> Response:
job_specs = list_job_specs()
return make_response(run_job(job_specs[job_id]), 200)
job_status = None
try:
job_status = run_job(job_specs[job_id])
except BaseException as e:
return make_response(
jsonify(
{
"error": str(e),
}
),
500,
)

return make_response(job_status, 200)


@application.route("/job-specs/<job_id>/logs", methods=["GET"])
Expand Down
3 changes: 2 additions & 1 deletion snuba/manual_jobs/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,11 @@ def run_job(job_spec: JobSpec) -> JobStatus:
if not job_spec.is_async:
current_job_status = _set_job_status(job_spec.job_id, JobStatus.FINISHED)
job_logger.info("[runner] job execution finished")
except BaseException as e:
except Exception as e:
current_job_status = _set_job_status(job_spec.job_id, JobStatus.FAILED)
job_logger.error(f"[runner] job execution failed {e}")
job_logger.info(f"[runner] exception {traceback.format_exc()}")
raise e
finally:
_release_job_lock(job_spec.job_id)

Expand Down
Loading