Merge pull request #1111 from kellycampbell/udp-timeout-workaround

Retry dns queries with TCP if UDP has an i/o timeout
This commit is contained in:
jetstack-bot 2018-11-30 12:12:12 +00:00 committed by GitHub
commit 670cd8564f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -144,7 +144,9 @@ func dnsQuery(fqdn string, rtype uint16, nameservers []string, recursive bool) (
udp := &dns.Client{Net: "udp", Timeout: DNSTimeout} udp := &dns.Client{Net: "udp", Timeout: DNSTimeout}
in, _, err = udp.Exchange(m, ns) in, _, err = udp.Exchange(m, ns)
if err == dns.ErrTruncated { if err == dns.ErrTruncated ||
(err != nil && strings.HasPrefix(err.Error(), "read udp") && strings.HasSuffix(err.Error(), "i/o timeout")) {
glog.V(6).Infof("UDP dns lookup failed, retrying with TCP: %v", err)
tcp := &dns.Client{Net: "tcp", Timeout: DNSTimeout} tcp := &dns.Client{Net: "tcp", Timeout: DNSTimeout}
// If the TCP request succeeds, the err will reset to nil // If the TCP request succeeds, the err will reset to nil
in, _, err = tcp.Exchange(m, ns) in, _, err = tcp.Exchange(m, ns)