Skip to content

Conversation

@d3flex
Copy link
Contributor

@d3flex d3flex commented Oct 22, 2025

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

@d3flex
Copy link
Contributor Author

d3flex commented Oct 22, 2025

  • I want to see where it will fail (some test failed on my side) and the codecov report
  • also I cant see where a test for this should go. there is t/10-jobs.t as an obvious candidate but it doesnt seem to cover the events

@codecov
Copy link

codecov bot commented Oct 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.26%. Comparing base (ad78558) to head (c8fe5b4).
⚠️ Report is 16 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@perlpunk
Copy link
Contributor

  • also I cant see where a test for this should go. there is t/10-jobs.t as an obvious candidate but it doesnt seem to cover the events

t/23-amqp.t looks right in this case. Take a job and call enqueue_restart on it

Copy link
Member

@okurz okurz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs tests

@d3flex d3flex force-pushed the feat/amqp_restart branch from 8632b55 to e5e5fd2 Compare October 23, 2025 07:44
Copy link
Member

@okurz okurz left a 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

@d3flex d3flex force-pushed the feat/amqp_restart branch from e5e5fd2 to 44e622e Compare October 23, 2025 08:12
@d3flex
Copy link
Contributor Author

d3flex commented Oct 23, 2025

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

image

@d3flex d3flex force-pushed the feat/amqp_restart branch from 44e622e to 0b69cf5 Compare October 23, 2025 13:05
@d3flex
Copy link
Contributor Author

d3flex commented Oct 23, 2025

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

updated.

@d3flex d3flex marked this pull request as ready for review October 23, 2025 13:06
@d3flex d3flex removed the not-ready label Oct 23, 2025
@perlpunk
Copy link
Contributor

With this commit once the job goes to execute its final stage, it will
check if it can be restarted. If yes, it will send the new job to
the minion queue via enqueue_restart, where now it should populate
the event.

The only change in this commit is that, if the job is restarted via enqueue_restart, it now publishes a restart event.
The description sounds overly complicated ("goes to execute its final stage").
" it will check if it can be restarted" - that's already happening without your commit.

How about: "When a job is enqueued to be restarted via the RETRY feature, it now publishes a job.restart event."

@d3flex
Copy link
Contributor Author

d3flex commented Oct 23, 2025

With this commit once the job goes to execute its final stage, it will
check if it can be restarted. If yes, it will send the new job to
the minion queue via enqueue_restart, where now it should populate
the event.

The only change in this commit is that, if the job is restarted via enqueue_restart, it now publishes a restart event. The description sounds overly complicated ("goes to execute its final stage"). " it will check if it can be restarted" - that's already happening without your commit.

How about: "When a job is enqueued to be restarted via the RETRY feature, it now publishes a job.restart event."

I avoid to reffer RETRY because is not the only path to enqueue_restart. are you good with When a job is enqueued to be restarted, it now publishes a job.restart event?

@perlpunk
Copy link
Contributor

When a job is enqueued to be restarted as part of the $job->done handling, a job.restart event is now published

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';
Copy link
Contributor

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)
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

@Martchus Martchus Oct 24, 2025

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.)

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});
Copy link
Contributor

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.

@d3flex d3flex force-pushed the feat/amqp_restart branch from 0b69cf5 to c3478ec Compare October 24, 2025 19:55
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]>
@d3flex d3flex force-pushed the feat/amqp_restart branch from c3478ec to c8fe5b4 Compare October 25, 2025 04:12
$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});
Copy link
Contributor

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.

Copy link
Contributor

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) = @_;
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants