Project

General

Profile

Actions

action #123625

open

No event emitted for jobs restarted via `RETRY`, jobs cancelled via `_job_stop_cluster`, and other cases

Added by AdamWill almost 2 years ago. Updated over 1 year ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Feature requests
Target version:
Start date:
2023-01-24
Due date:
% Done:

0%

Estimated time:

Description

If you use the RETRY auto-retry mechanism, AFAICS, when the job is restarted, no event is emitted. Logically speaking, I'd expect a job_restart event to be emitted, as it is when you restart a job manually.

This seems like it should be easy to fix so I was just going to send a PR, but actually the codepaths are kind of long and complex and there's a question without an obvious answer (to me).

RETRY handling starts in lib/OpenQA/Schema/Results/Jobs.pm done(), which checks if RETRY is set and the job failed and calls $self->auto_duplicate, which goes through a whole other pile of functions that wind up actually restarting the job. So I could just stick an emit_event in that pile somewhere - there's a precedent for using emit_event in that file, as OpenQA::App->singleton->emit_event(), in update_result(). However, there's another path where something calls $self->auto_duplicate, and that thing emits the event itself; in lib/OpenQA/WebAPI/Controller/API/V1/Job.pm, _restart() calls OpenQA::Resource::Jobs::job_restart(), which calls $job->auto_duplicate(), and then _restart() emits the event.

So, what's the best way to do this? Move the event emission somewhere under $job->auto_duplicate() and drop the emit_event() from _restart() in API/V1/Job.pm? Or have done() emit the event after calling $self->auto_duplicate(), kinda mirroring what _restart() does? Or is there a better idea? I'm not really sure.

Actions

Also available in: Atom PDF