allow deferrable_actions exceptions to device deferrals
This commit is contained in:
@@ -236,9 +236,16 @@ sub jq_defer {
|
||||
# seeing as defer is only triggered by an SNMP connect failure, this
|
||||
# behaviour seems reasonable, to me (or desirable, perhaps).
|
||||
|
||||
# the deferrable_actions setting exists as a workaround to this behaviour
|
||||
# should it be needed by any action (that is, per-device action but
|
||||
# do not increment deferrals count and simply try to run again).
|
||||
|
||||
try {
|
||||
schema(vars->{'tenant'})->txn_do(sub {
|
||||
if ($job->device) {
|
||||
if ($job->device
|
||||
and not scalar grep { $job->action eq $_ }
|
||||
@{ setting('deferrable_actions') || [] }) {
|
||||
|
||||
schema(vars->{'tenant'})->resultset('DeviceSkip')->find_or_create({
|
||||
backend => setting('workers')->{'BACKEND'}, device => $job->device,
|
||||
},{ key => 'device_skip_pkey' })->increment_deferrals;
|
||||
|
||||
@@ -14,10 +14,10 @@ register_worker({ phase => 'check', driver => 'direct' }, sub {
|
||||
and (not blessed $job->device or not $job->device->in_storage)) {
|
||||
|
||||
config->{'snmp_try_slow_connect'} = false;
|
||||
return Status->info("running with fast SNMP timeouts for initial discover");
|
||||
debug "running with fast SNMP timeouts for initial discover";
|
||||
}
|
||||
|
||||
return Status->info("running with configured SNMP timeouts");
|
||||
debug "running with configured SNMP timeouts";
|
||||
});
|
||||
|
||||
true;
|
||||
|
||||
@@ -22,7 +22,7 @@ register_worker({ phase => 'check' }, sub {
|
||||
return Status->error('Missing device (-d).')
|
||||
unless defined shift->device;
|
||||
|
||||
return Status->info("snapshot skipped: please run a loadmibs job first")
|
||||
return Status->defer("snapshot skipped: please run a loadmibs job first")
|
||||
unless schema('netdisco')->resultset('SNMPObject')->count();
|
||||
|
||||
return Status->done('Snapshot is able to run');
|
||||
|
||||
@@ -67,10 +67,10 @@ sub _make_new {
|
||||
return $new;
|
||||
}
|
||||
|
||||
sub done { shift->_make_new('done', @_) }
|
||||
sub info { shift->_make_new('info', @_) }
|
||||
sub defer { shift->_make_new('defer', @_) }
|
||||
sub error { shift->_make_new('error', @_) }
|
||||
sub done { shift->_make_new('done', @_) } # <- jq_complete
|
||||
sub info { shift->_make_new('info', @_) } # <- jq_complete
|
||||
sub defer { shift->_make_new('defer', @_) } # <- jq_defer
|
||||
sub error { shift->_make_new('error', @_) } # <- jq_complete
|
||||
|
||||
=head2 is_ok
|
||||
|
||||
|
||||
@@ -572,6 +572,9 @@ driver_priority:
|
||||
cli: 200
|
||||
snmp: 100
|
||||
|
||||
deferrable_actions:
|
||||
- 'snapshot'
|
||||
|
||||
# ---------------
|
||||
# GraphViz Export
|
||||
# ---------------
|
||||
|
||||
Reference in New Issue
Block a user