Skip to content

Commit

Permalink
More logs cleanup
Browse files Browse the repository at this point in the history
Use more `debugf` in places that look definitely like developer's debug
which is most probably useless to an end user.

Promote some debug errors that looks more like warnings to use Warnf
rather than Debugf.

Signed-off-by: Kir Kolyshkin <[email protected]>
  • Loading branch information
kolyshkin committed Nov 18, 2019
1 parent c5aec55 commit 0f20b88
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
14 changes: 7 additions & 7 deletions resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ 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
}
Expand Down Expand Up @@ -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
}

Expand All @@ -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
}
Expand All @@ -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
Expand Down
16 changes: 8 additions & 8 deletions sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ func (sb *sandbox) resolveName(req string, networkName string, epList []*endpoin
func (sb *sandbox) SetKey(basePath string) error {
start := time.Now()
defer func() {
logrus.Debugf("sandbox set key processing took %s for container %s", time.Since(start), sb.ContainerID())
debugf("sandbox set key processing took %s for container %s", time.Since(start), sb.ContainerID())
}()

if basePath == "" {
Expand Down Expand Up @@ -691,7 +691,7 @@ func (sb *sandbox) SetKey(basePath string) error {
}

func (sb *sandbox) EnableService() (err error) {
logrus.Debugf("EnableService %s START", sb.containerID)
debugf("EnableService %s START", sb.containerID)
defer func() {
if err != nil {
sb.DisableService()
Expand All @@ -705,12 +705,12 @@ func (sb *sandbox) EnableService() (err error) {
ep.enableService()
}
}
logrus.Debugf("EnableService %s DONE", sb.containerID)
debugf("EnableService %s DONE", sb.containerID)
return nil
}

func (sb *sandbox) DisableService() (err error) {
logrus.Debugf("DisableService %s START", sb.containerID)
debugf("DisableService %s START", sb.containerID)
failedEps := []string{}
defer func() {
if len(failedEps) > 0 {
Expand All @@ -726,7 +726,7 @@ func (sb *sandbox) DisableService() (err error) {
ep.disableService()
}
}
logrus.Debugf("DisableService %s DONE", sb.containerID)
debugf("DisableService %s DONE", sb.containerID)
return nil
}

Expand All @@ -735,7 +735,7 @@ func releaseOSSboxResources(osSbox osl.Sandbox, ep *endpoint) {
// Only remove the interfaces owned by this endpoint from the sandbox.
if ep.hasInterface(i.SrcName()) {
if err := i.Remove(); err != nil {
logrus.Debugf("Remove interface %s failed: %v", i.SrcName(), err)
logrus.WithError(err).Warnf("Remove interface %s failed", i.SrcName())
}
}
}
Expand All @@ -749,7 +749,7 @@ func releaseOSSboxResources(osSbox osl.Sandbox, ep *endpoint) {
if len(vip) > 0 && lbModeIsDSR {
ipNet := &net.IPNet{IP: vip, Mask: net.CIDRMask(32, 32)}
if err := osSbox.RemoveAliasIP(osSbox.GetLoopbackIfaceName(), ipNet); err != nil {
logrus.WithError(err).Debugf("failed to remove virtual ip %v to loopback", ipNet)
logrus.WithError(err).Warnf("Failed to remove virtual ip %v to loopback", ipNet)
}
}

Expand All @@ -760,7 +760,7 @@ func releaseOSSboxResources(osSbox osl.Sandbox, ep *endpoint) {
// Remove non-interface routes.
for _, r := range joinInfo.StaticRoutes {
if err := osSbox.RemoveStaticRoute(r); err != nil {
logrus.Debugf("Remove route failed: %v", err)
logrus.WithError(err).Warnf("Remove route failed")
}
}
}
Expand Down

0 comments on commit 0f20b88

Please sign in to comment.