device_ignore table to track devices to skip in polling

This commit is contained in:
Oliver Gorwits
2017-05-21 14:52:33 +01:00
parent 47a5f40efe
commit ed193356f8
6 changed files with 65 additions and 8 deletions

View File

@@ -30,11 +30,17 @@ sub _getsome {
return () if ((!defined $num_slots) or ($num_slots < 1));
return () if ((!defined $where) or (ref {} ne ref $where));
my $rs = schema('netdisco')->resultset('Admin')
->search(
{ status => 'queued', %$where },
{ order_by => 'random()', rows => $num_slots },
);
my $fqdn = hostfqdn || 'localhost';
my $jobs = schema('netdisco')->resultset('Admin');
my $rs = $jobs->search({
status => 'queued',
device => { '-not_in' => $jobs->correlate('ignored')->search({
backend => $fqdn,
-or => [{ failures => { '>=', 10 } },{ '-bool' => 'ignore' }],
}, { columns => 'device' })->as_query },
%$where,
}, { order_by => 'random()', rows => $num_slots });
my @returned = ();
while (my $job = $rs->next) {