From b213d0b9af2d33aaae746588b3d66d72ca376d3f Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 11 Feb 2018 12:07:12 +0000 Subject: [PATCH] cancel early if we can --- lib/App/Netdisco/Worker/Plugin/Discover.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/App/Netdisco/Worker/Plugin/Discover.pm b/lib/App/Netdisco/Worker/Plugin/Discover.pm index 96c4dc05..f3b48352 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover.pm @@ -19,6 +19,10 @@ register_worker({ phase => 'check' }, sub { return Status->defer("discover skipped: $device is pseudo-device") if $device->is_pseudo; + # runner has already called get_device to promote $job->device + return $job->cancel("fresh discover cancelled: $device already known") + if $device->in_storage and $job->subaction eq 'with-nodes'; + return Status->defer("discover deferred: $device is not discoverable") unless is_discoverable_now($device);