shorten timeout on dns for timeoutdevices report
This commit is contained in:
		| @@ -105,7 +105,7 @@ sub ipv4_from_hostname { | ||||
|   return undef; | ||||
| } | ||||
|  | ||||
| =head2 hostnames_resolve_async( $ips ) | ||||
| =head2 hostnames_resolve_async( \@ips, \@timeouts? ) | ||||
|  | ||||
| This method uses a fully asynchronous and high-performance pure-perl stub | ||||
| resolver C<AnyEvent::DNS>. | ||||
| @@ -114,14 +114,21 @@ Given a reference to an array of hashes will resolve the C<IPv4> or C<IPv6> | ||||
| address in the C<ip>, C<alias>, or C<device> key of each hash into its | ||||
| hostname which will be inserted in the C<dns> key of the hash. | ||||
|  | ||||
| Optionally provide a set of timeout values in seconds which is also the | ||||
| number of resolver attempts. The default is C<< [2,5,5] >>. | ||||
|  | ||||
| Returns the supplied reference to an array of hashes with dns values for | ||||
| addresses which resolved. | ||||
|  | ||||
| =cut | ||||
|  | ||||
| sub hostnames_resolve_async { | ||||
|   my $ips  = shift; | ||||
|   my ($ips, $timeouts) = @_; | ||||
|   return [] unless $ips and ref [] eq ref $ips; | ||||
|   $timeouts ||= [2,5,5]; | ||||
|  | ||||
|   my $skip = setting('dns')->{'no'}; | ||||
|   AnyEvent::DNS::resolver->timeout(@$timeouts); | ||||
|  | ||||
|   # Set up the condvar | ||||
|   my $done = AE::cv; | ||||
| @@ -151,6 +158,7 @@ sub hostnames_resolve_async { | ||||
|   $done->recv; | ||||
|    | ||||
|   # Remove reference to resolver so that we close sockets | ||||
|   # and allow return to any instance defaults we have changed | ||||
|   undef $AnyEvent::DNS::RESOLVER if $AnyEvent::DNS::RESOLVER; | ||||
|  | ||||
|   return $ips; | ||||
|   | ||||
| @@ -16,11 +16,11 @@ register_admin_task({ | ||||
| ajax '/ajax/content/admin/timedoutdevices' => require_role admin => sub { | ||||
|     my @set = schema('netdisco')->resultset('DeviceSkip')->search({ | ||||
|       deferrals => { '>' => 0 } | ||||
|     },{ rows => 50, order_by => | ||||
|     },{ rows => (setting('dns')->{max_outstanding} || 50), order_by => | ||||
|       [{ -desc => 'deferrals' }, { -asc => [qw/device backend/] }] | ||||
|     })->hri->all; | ||||
|  | ||||
|     my $results = hostnames_resolve_async(\@set); | ||||
|     my $results = hostnames_resolve_async(\@set, [2,2,2]); | ||||
|  | ||||
|     content_type('text/html'); | ||||
|     template 'ajax/admintask/timedoutdevices.tt', { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user