Remove dupe restriction on job queue, try for smarter *all queuing (closes #41)

This commit is contained in:
Oliver Gorwits
2013-10-16 23:38:58 +01:00
parent e7dac14cb0
commit c6925d1c1a
6 changed files with 30 additions and 25 deletions

View File

@@ -16,8 +16,15 @@ use namespace::clean;
sub _walk_body {
my ($self, $job_type, $job) = @_;
my $devices = schema('netdisco')->resultset('Device')->get_column('ip');
my $jobqueue = schema('netdisco')->resultset('Admin');
my $devices = schema('netdisco')->resultset('Device')
->search({ip => { -not_in =>
$jobqueue->search({
device => { '!=' => undef},
action => $job_type,
status => { -like => 'queued%' },
})->get_column('device')->as_query
}})->get_column('ip');
if ($job->subaction and $job->subaction eq 'after-discoverall') {
# make sure there are no incomplete discover jobs queued
@@ -29,17 +36,7 @@ sub _walk_body {
if $discover;
}
schema('netdisco')->txn_do(sub {
# clean up user submitted jobs older than 1min,
# assuming skew between schedulers' clocks is not greater than 1min
$jobqueue->search({
action => $job_type,
status => 'queued',
entered => { '<' => \"(now() - interval '1 minute')" },
})->delete;
# is scuppered by any user job submitted in last 1min (bad), or
# any similar job from another scheduler (good)
schema('netdisco')->resultset('Admin')->txn_do_locked(sub {
$jobqueue->populate([
map {{
device => $_,

View File

@@ -17,20 +17,17 @@ use namespace::clean;
sub discoverall {
my ($self, $job) = @_;
my $devices = schema('netdisco')->resultset('Device')->get_column('ip');
my $jobqueue = schema('netdisco')->resultset('Admin');
my $devices = schema('netdisco')->resultset('Device')
->search({ip => { -not_in =>
$jobqueue->search({
device => { '!=' => undef},
action => 'discover',
status => { -like => 'queued%' },
})->get_column('device')->as_query
}})->get_column('ip');
schema('netdisco')->txn_do(sub {
# clean up user submitted jobs older than 1min,
# assuming skew between schedulers' clocks is not greater than 1min
$jobqueue->search({
action => 'discover',
status => 'queued',
entered => { '<' => \"(now() - interval '1 minute')" },
})->delete;
# is scuppered by any user job submitted in last 1min (bad), or
# any similar job from another scheduler (good)
schema('netdisco')->resultset('Admin')->txn_do_locked(sub {
$jobqueue->populate([
map {{
device => $_,