Skip to content

Commit f4b0cb6

Browse files
committed
Load AMQP plugin into the Gru tasks
Makes possible to the minion tasks to emit events, as it makes the AMQP plugin available in its context. The `one_tick` is called to trigger the `next_tick` in the `register` function of the AMPQ module immediately, otherwise it seems like it is registered late and the event is not emitted. issue: https://progress.opensuse.org/issues/190557 Signed-off-by: Ioannis Bonatakis <[email protected]>
1 parent 2f9dd60 commit f4b0cb6

File tree

1 file changed

+14
-1
lines changed
  • lib/OpenQA/Shared/Plugin

1 file changed

+14
-1
lines changed

lib/OpenQA/Shared/Plugin/Gru.pm

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use DBIx::Class::Timestamps 'now';
1010
use OpenQA::App;
1111
use OpenQA::Schema;
1212
use OpenQA::Shared::GruJob;
13-
use OpenQA::Log qw(log_debug log_info);
13+
use OpenQA::Log qw(log_debug log_info log_error);
1414
use OpenQA::Utils qw(sharedir);
1515
use Mojo::Pg;
1616
use Mojo::Promise;
@@ -98,6 +98,19 @@ sub register ($self, $app, $config) {
9898
});
9999

100100
$self->register_tasks;
101+
my $plugins = $app->config->{global}->{plugins};
102+
if (defined $plugins && $plugins =~ /\bAMQP\b/) {
103+
push @{$app->plugins->namespaces}, 'OpenQA::WebAPI::Plugin'
104+
unless grep { $_ eq 'OpenQA::WebAPI::Plugin' } @{$app->plugins->namespaces};
105+
106+
try {
107+
$app->plugin('AMQP');
108+
Mojo::IOLoop->singleton->one_tick;
109+
}
110+
catch ($e) {
111+
log_error("Failed to load AMQP plugin for Gru: $e");
112+
}
113+
}
101114

102115
# Enable the Minion Admin interface under /minion
103116
my $auth = $app->routes->under('/minion')->to('session#ensure_admin');

0 commit comments

Comments
 (0)