Hook up the retryable tasks with hydra-notify
This commit is contained in:
parent
c0e86faa78
commit
ea3ae0693e
|
@ -6,6 +6,7 @@ use utf8;
|
||||||
use base 'DBIx::Class::ResultSet';
|
use base 'DBIx::Class::ResultSet';
|
||||||
use List::Util qw(max);
|
use List::Util qw(max);
|
||||||
use Hydra::Math qw(exponential_backoff);
|
use Hydra::Math qw(exponential_backoff);
|
||||||
|
use Hydra::Task;
|
||||||
|
|
||||||
=head2 get_seconds_to_next_retry
|
=head2 get_seconds_to_next_retry
|
||||||
|
|
||||||
|
|
|
@ -254,7 +254,7 @@ sub failure {
|
||||||
my $event_labels = $self->prom_labels_for_task($task);
|
my $event_labels = $self->prom_labels_for_task($task);
|
||||||
|
|
||||||
if (defined($task->{"record"})) {
|
if (defined($task->{"record"})) {
|
||||||
if ($task->{"record"}->{"attempts"} > 100) {
|
if ($task->{"record"}->attempts > 100) {
|
||||||
$self->{"prometheus"}->inc("notify_plugin_drop", $event_labels);
|
$self->{"prometheus"}->inc("notify_plugin_drop", $event_labels);
|
||||||
$task->{"record"}->delete();
|
$task->{"record"}->delete();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -101,10 +101,12 @@ for my $build ($db->resultset('Builds')->search(
|
||||||
$task_dispatcher->dispatch_event($event);
|
$task_dispatcher->dispatch_event($event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $taskretries = $db->resultset('TaskRetries');
|
||||||
|
|
||||||
# Process incoming notifications.
|
# Process incoming notifications.
|
||||||
while (!$queued_only) {
|
while (!$queued_only) {
|
||||||
$prom->inc("event_loop_iterations");
|
$prom->inc("event_loop_iterations");
|
||||||
my $messages = $listener->block_for_messages();
|
my $messages = $listener->block_for_messages($taskretries->get_seconds_to_next_retry());
|
||||||
while (my $message = $messages->()) {
|
while (my $message = $messages->()) {
|
||||||
$prom->set("event_received", time());
|
$prom->set("event_received", time());
|
||||||
my $channelName = $message->{"channel"};
|
my $channelName = $message->{"channel"};
|
||||||
|
@ -128,4 +130,10 @@ while (!$queued_only) {
|
||||||
print STDERR "error processing message '$payload' on channel '$channelName': $@\n";
|
print STDERR "error processing message '$payload' on channel '$channelName': $@\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $task = $taskretries->getRetryableTask();
|
||||||
|
if (defined($task)) {
|
||||||
|
$task_dispatcher->dispatchTask($task);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue