-
Couldn't load subscription status.
- Fork 219
Emit restart events when a job is enqueued #6816
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
base: master
Are you sure you want to change the base?
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6816 +/- ##
=======================================
Coverage 99.26% 99.26%
=======================================
Files 402 402
Lines 41373 41384 +11
=======================================
+ Hits 41067 41078 +11
Misses 306 306 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs tests
8632b55 to
e5e5fd2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code looks good so far. I suggest you do a manual system test with a local openQA instance and ensure that no duplicate events are sent.
Also in your commit message I don't quite understand "With this commit once the job goes to its end, it will check if it can restarted and if it fulfills the criteria". What "end" and what "criteria"? Also "check if it can restarted" is grammatically incorrect
e5e5fd2 to
44e622e
Compare
44e622e to
0b69cf5
Compare
updated. |
The only change in this commit is that, if the job is restarted via How about: "When a job is enqueued to be restarted via the |
I avoid to reffer |
|
When a job is enqueued to be restarted as part of the |
t/23-amqp.t
Outdated
| qr/Enqueued restarting openQA job 99945 via Minion job \d+/, 'Debug log for enqueue_restart is present'; | ||
| ok $minion_id, 'Got a Minion job ID back'; | ||
| # each event contains keys(headers args body) | ||
| is scalar(%published), 3, 'Exactly one event was published'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The number and the description are inconsistent.
t/23-amqp.t
Outdated
| combined_like { $minion_id = $test_job->enqueue_restart } | ||
| qr/Enqueued restarting openQA job 99945 via Minion job \d+/, 'Debug log for enqueue_restart is present'; | ||
| ok $minion_id, 'Got a Minion job ID back'; | ||
| # each event contains keys(headers args body) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove this comment. If this is important it should be checked with code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will answer in your both comments here.
The amqp event contains three things, right? It has a headers, a body and the args. This is one amqp and the description is emphasize to that. the comment+ the description intended to make that clear.
the importance is that there is one event and not what is in this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just remove the comment then. It doesn't help me understand the test code better. (And it lacks punctuation.)
lib/OpenQA/Schema/Result/Jobs.pm
Outdated
| my $openqa_job_id = $self->id; | ||
| my $minion_job_id = OpenQA::App->singleton->gru->enqueue(restart_job => [$openqa_job_id], $options)->{minion_id}; | ||
| log_debug "Enqueued restarting openQA job $openqa_job_id via Minion job $minion_job_id"; | ||
| OpenQA::App->singleton->emit_event(openqa_job_restart => {id => $openqa_job_id}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure whether this is the right place. Here the job hasn't actually been restarted yet because the according Minion job has only been enqueued. I would prefer to emit the event only when the restart has actually successfully happened.
0b69cf5 to
c3478ec
Compare
Use the `auto_duplicate` to emit an event as it is invoked by other functions which try to handle individual job restarts. That should make sure that the event is send to AMQP for jobs with `RETRY` once it is actually triggered. issue: https://progress.opensuse.org/issues/190557 Signed-off-by: Ioannis Bonatakis <[email protected]>
c3478ec to
c8fe5b4
Compare
| $dup->{cluster_cloned} = {map { $_ => $clones->{$_}->{clone} } keys %$clones}; | ||
| $dup->{comments_created} = $args->{comments}; | ||
| log_debug("Job $job_id duplicated as $clone_id"); | ||
| OpenQA::Events->singleton->emit_event('job_restart', data => {id => $clone_id}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto_duplicate is also called when doing a restart via API or web UI, and in that case the code emits an event already, see
https://github.com/os-autoinst/openQA/blob/master/lib/OpenQA/WebAPI/Controller/API/V1/Job.pm#L821
So we would get two events.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, so please take care we don't get two events.
| my $mock_events = Test::MockModule->new('OpenQA::Events'); | ||
| $mock_events->redefine( | ||
| emit_event => sub { | ||
| my ($self, $type, %args) = @_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use signatures in new code.

With this commit once the job goes to its end, it will check if it can restarted and if it fulfills the criteria, it will send the new job to the minion queue via
enqueue_restart, where now it should populate the event.issue: https://progress.opensuse.org/issues/190557