summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2017-08-08 15:37:36 +0300
committerSteve Kemp <steve@steve.org.uk>2017-08-08 15:37:36 +0300
commit70b13e92297905631629a05e827d70e98c3f422d (patch)
tree1e74bd070e55926833c90687d2661ac262cc0e72
parent3ddad643888312cfb32b27aee3a057106e1895e1 (diff)
Sanity-check DNS on a per-protocol basis.
When a failure occurs in looking up IPv4 addresses we confirm that, similarly when/if IPv6 lookups fail we confirm that before raising the alert.
-rw-r--r--lib/custodian/protocoltest/http.rb20
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/custodian/protocoltest/http.rb b/lib/custodian/protocoltest/http.rb
index 88ac568..32073f8 100644
--- a/lib/custodian/protocoltest/http.rb
+++ b/lib/custodian/protocoltest/http.rb
@@ -59,7 +59,7 @@ module Custodian
# raise an alert, but if it is this false-error then we
# will silently disable this test-run.
#
- def ignore_failure?
+ def ignore_failure?( protocol )
# IP addresses we found for the host
ips = []
@@ -85,11 +85,16 @@ module Custodian
Resolv::DNS.open do |dns|
- ress = dns.getresources(target, Resolv::DNS::Resource::IN::A)
- ress.map { |r| ips.push(r.address.to_s) }
+ if ( protocol == :ipv4 )
+ ress = dns.getresources(target, Resolv::DNS::Resource::IN::A)
+ ress.map { |r| ips.push(r.address.to_s) }
+ elsif ( protocol == :ipv6 )
- ress = dns.getresources(target, Resolv::DNS::Resource::IN::AAAA)
- ress.map { |r| ips.push(r.address.to_s) }
+ ress = dns.getresources(target, Resolv::DNS::Resource::IN::AAAA)
+ ress.map { |r| ips.push(r.address.to_s) }
+ else
+ raise ArgumentError, "Sanity-checking DNS-failure of unknown type"
+ end
end
end
rescue Timeout::Error => _e
@@ -409,7 +414,7 @@ module Custodian
rescue Curl::Err::TooManyRedirectsError
errors << "#{protocol_msg}: More than 10 redirections."
rescue Curl::Err::HostResolutionError => x
- resolution_errors << "#{protocol_msg}: #{x.class}: #{x.message}\n #{x.backtrace.join("\n ")}."
+ resolution_errors << "#{protocol_msg}: #{x.class}: #{x.message}\n #{x.backtrace.join("\n ")}." unless ignore_failure?( resolve_mode)
rescue => x
errors << "#{protocol_msg}: #{x.class}: #{x.message}\n #{x.backtrace.join("\n ")}."
@@ -432,9 +437,6 @@ module Custodian
# uh-oh! Resolution failed on both protocols!
if resolution_errors.length > 1
-
- return Custodian::TestResult::TEST_SKIPPED if ignore_failure?
-
errors << "DNS Error when resolving host - #{resolution_errors.join(',')}"
end