From 7b9e7f4deb282c028bef31a4b3b03f08163a69c6 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 11 Jun 2017 14:45:59 +0100 Subject: [PATCH] device skips should not be used on priority jobs --- lib/App/Netdisco/JobQueue/PostgreSQL.pm | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/lib/App/Netdisco/JobQueue/PostgreSQL.pm b/lib/App/Netdisco/JobQueue/PostgreSQL.pm index 984383f1..4f39bc11 100644 --- a/lib/App/Netdisco/JobQueue/PostgreSQL.pm +++ b/lib/App/Netdisco/JobQueue/PostgreSQL.pm @@ -38,15 +38,8 @@ sub _getsome { return () if ((!defined $num_slots) or ($num_slots < 1)); return () if ((!defined $where) or (ref {} ne ref $where)); - $fqdn ||= (hostfqdn || 'localhost'); - my $jobs = schema('netdisco')->resultset('Admin'); - - my $rs = $jobs->search({ - status => 'queued', - device => { '-not_in' => - $jobs->skipped($fqdn, setting('workers')->{'max_deferrals'}) - ->columns('device')->as_query }, - %$where, + my $rs = schema('netdisco')->resultset('Admin')->search({ + status => 'queued', %$where, }, { order_by => 'random()', rows => $num_slots }); my @returned = (); @@ -57,9 +50,15 @@ sub _getsome { } sub jq_getsome { - return _getsome(shift, - { action => { -in => setting('job_prio')->{'normal'} } } - ); + my $jobs = schema('netdisco')->resultset('Admin'); + $fqdn ||= (hostfqdn || 'localhost'); + + return _getsome(shift, { + action => { -in => setting('job_prio')->{'normal'} }, + device => { -not_in => + $jobs->skipped($fqdn, setting('workers')->{'max_deferrals'}) + ->columns('device')->as_query }, + }); } sub jq_getsomep {