-
Notifications
You must be signed in to change notification settings - Fork 880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
resolver: less debug #2475
Open
kolyshkin
wants to merge
2
commits into
moby:master
Choose a base branch
from
kolyshkin:resolver-debug
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
resolver: less debug #2475
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// +build debug_log | ||
package libnetwork | ||
|
||
import "github.com/sirupsen/logrus" | ||
|
||
func debugf(format string, args ...interface{}) { | ||
logrus.Debugf(format, args...) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// +build !debug_log | ||
package libnetwork | ||
|
||
func debugf(format string, args ...interface{}) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -247,15 +247,15 @@ func (r *resolver) handleIPQuery(name string, query *dns.Msg, ipType int) (*dns. | |
|
||
if addr == nil && ipv6Miss { | ||
// Send a reply without any Answer sections | ||
logrus.Debugf("[resolver] lookup name %s present without IPv6 address", name) | ||
logrus.Warnf("[resolver] lookup name %s present without IPv6 address", name) | ||
resp := createRespMsg(query) | ||
return resp, nil | ||
} | ||
if addr == nil { | ||
return nil, nil | ||
} | ||
|
||
logrus.Debugf("[resolver] lookup for %s: IP %v", name, addr) | ||
debugf("[resolver] lookup for %s: IP %v", name, addr) | ||
|
||
resp := createRespMsg(query) | ||
if len(addr) > 1 { | ||
|
@@ -296,7 +296,7 @@ func (r *resolver) handlePTRQuery(ptr string, query *dns.Msg) (*dns.Msg, error) | |
return nil, nil | ||
} | ||
|
||
logrus.Debugf("[resolver] lookup for IP %s: name %s", parts[0], host) | ||
debugf("[resolver] lookup for IP %s: name %s", parts[0], host) | ||
fqdn := dns.Fqdn(host) | ||
|
||
resp := new(dns.Msg) | ||
|
@@ -453,7 +453,7 @@ func (r *resolver) ServeDNS(w dns.ResponseWriter, query *dns.Msg) { | |
continue | ||
} | ||
queryType := dns.TypeToString[query.Question[0].Qtype] | ||
logrus.Debugf("[resolver] query %s (%s) from %s, forwarding to %s:%s", name, queryType, | ||
debugf("[resolver] query %s (%s) from %s, forwarding to %s:%s", name, queryType, | ||
extConn.LocalAddr().String(), proto, extDNS.IPStr) | ||
|
||
// Timeout has to be set for every IO operation. | ||
|
@@ -477,7 +477,7 @@ func (r *resolver) ServeDNS(w dns.ResponseWriter, query *dns.Msg) { | |
err = co.WriteMsg(query) | ||
if err != nil { | ||
r.forwardQueryEnd() | ||
logrus.Debugf("[resolver] send to DNS server failed, %s", err) | ||
logrus.Warnf("[resolver] send to DNS server failed, %s", err) | ||
continue | ||
} | ||
|
||
|
@@ -486,24 +486,24 @@ func (r *resolver) ServeDNS(w dns.ResponseWriter, query *dns.Msg) { | |
// client can retry over TCP | ||
if err != nil && err != dns.ErrTruncated { | ||
r.forwardQueryEnd() | ||
logrus.Debugf("[resolver] read from DNS server failed, %s", err) | ||
logrus.Warnf("[resolver] read from DNS server failed, %s", err) | ||
continue | ||
} | ||
r.forwardQueryEnd() | ||
|
||
if resp == nil { | ||
logrus.Debugf("[resolver] external DNS %s:%s returned empty response for %q", proto, extDNS.IPStr, name) | ||
logrus.Warnf("[resolver] external DNS %s:%s returned empty response for %q", proto, extDNS.IPStr, name) | ||
break | ||
} | ||
switch resp.Rcode { | ||
case dns.RcodeServerFailure, dns.RcodeRefused: | ||
// Server returned FAILURE: continue with the next external DNS server | ||
// Server returned REFUSED: this can be a transitional status, so continue with the next external DNS server | ||
logrus.Debugf("[resolver] external DNS %s:%s responded with %s for %q", proto, extDNS.IPStr, statusString(resp.Rcode), name) | ||
logrus.Warnf("[resolver] external DNS %s:%s responded with %s for %q", proto, extDNS.IPStr, statusString(resp.Rcode), name) | ||
continue | ||
case dns.RcodeNameError: | ||
// Server returned NXDOMAIN. Stop resolution if it's an authoritative answer (see RFC 8020: https://tools.ietf.org/html/rfc8020#section-2) | ||
logrus.Debugf("[resolver] external DNS %s:%s responded with %s for %q", proto, extDNS.IPStr, statusString(resp.Rcode), name) | ||
logrus.Warnf("[resolver] external DNS %s:%s responded with %s for %q", proto, extDNS.IPStr, statusString(resp.Rcode), name) | ||
if resp.Authoritative { | ||
break | ||
} | ||
|
@@ -512,7 +512,7 @@ func (r *resolver) ServeDNS(w dns.ResponseWriter, query *dns.Msg) { | |
// All is well | ||
default: | ||
// Server gave some error. Log the error, and continue with the next external DNS server | ||
logrus.Debugf("[resolver] external DNS %s:%s responded with %s (code %d) for %q", proto, extDNS.IPStr, statusString(resp.Rcode), resp.Rcode, name) | ||
logrus.Warnf("[resolver] external DNS %s:%s responded with %s (code %d) for %q", proto, extDNS.IPStr, statusString(resp.Rcode), resp.Rcode, name) | ||
continue | ||
} | ||
answers := 0 | ||
|
@@ -522,17 +522,17 @@ func (r *resolver) ServeDNS(w dns.ResponseWriter, query *dns.Msg) { | |
case dns.TypeA: | ||
answers++ | ||
ip := rr.(*dns.A).A | ||
logrus.Debugf("[resolver] received A record %q for %q from %s:%s", ip, h.Name, proto, extDNS.IPStr) | ||
debugf("[resolver] received A record %q for %q from %s:%s", ip, h.Name, proto, extDNS.IPStr) | ||
r.backend.HandleQueryResp(h.Name, ip) | ||
case dns.TypeAAAA: | ||
answers++ | ||
ip := rr.(*dns.AAAA).AAAA | ||
logrus.Debugf("[resolver] received AAAA record %q for %q from %s:%s", ip, h.Name, proto, extDNS.IPStr) | ||
debugf("[resolver] received AAAA record %q for %q from %s:%s", ip, h.Name, proto, extDNS.IPStr) | ||
r.backend.HandleQueryResp(h.Name, ip) | ||
} | ||
} | ||
if resp.Answer == nil || answers == 0 { | ||
logrus.Debugf("[resolver] external DNS %s:%s did not return any %s records for %q", proto, extDNS.IPStr, queryType, name) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same for this one There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
debugf("[resolver] external DNS %s:%s did not return any %s records for %q", proto, extDNS.IPStr, queryType, name) | ||
} | ||
resp.Compress = true | ||
break | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering if we still have some debugging about this case (I know this has sometimes been useful when debugging if requests are actually forwarded, and if so, to which DNS)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well,
tcpdump
for the rescue.