Skip to content

Commit

Permalink
Merge pull request #1368 from rancher-sandbox/dns-trace
Browse files Browse the repository at this point in the history
Don't log DNS queries by default
  • Loading branch information
AkihiroSuda authored Feb 15, 2023
2 parents 2992029 + 3eaa898 commit f086bc4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
7 changes: 6 additions & 1 deletion cmd/limactl/hostagent.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,10 @@ func initLogrus(stderr io.Writer) {
logrus.SetOutput(stderr)
// JSON logs are parsed in pkg/hostagent/events.Watcher()
logrus.SetFormatter(new(logrus.JSONFormatter))
logrus.SetLevel(logrus.DebugLevel)
// HostAgent logging is one level more verbose than the start command itself
if logrus.GetLevel() == logrus.DebugLevel {
logrus.SetLevel(logrus.TraceLevel)
} else {
logrus.SetLevel(logrus.DebugLevel)
}
}
10 changes: 5 additions & 5 deletions pkg/hostagent/dns/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (s *Server) Shutdown() {
}

func newStaticClientConfig(ips []string) (*dns.ClientConfig, error) {
logrus.Debugf("newStaticClientConfig creating config for the the following IPs: %v", ips)
logrus.Tracef("newStaticClientConfig creating config for the the following IPs: %v", ips)
s := ``
for _, ip := range ips {
s += fmt.Sprintf("nameserver %s\n", ip)
Expand Down Expand Up @@ -152,7 +152,7 @@ func (h *Handler) handleQuery(w dns.ResponseWriter, req *dns.Msg) {
)
defer w.Close()
reply.SetReply(req)
logrus.Debugf("handleQuery received DNS query: %v", req)
logrus.Tracef("handleQuery received DNS query: %v", req)
for _, q := range req.Question {
hdr := dns.RR_Header{
Name: q.Name,
Expand Down Expand Up @@ -315,7 +315,7 @@ func (h *Handler) handleQuery(w dns.ResponseWriter, req *dns.Msg) {
}

func (h *Handler) handleDefault(w dns.ResponseWriter, req *dns.Msg) {
logrus.Debugf("handleDefault for %v", req)
logrus.Tracef("handleDefault for %v", req)
for _, client := range h.clients {
for _, srv := range h.clientConfig.Servers {
addr := fmt.Sprintf("%s:%s", srv, h.clientConfig.Port)
Expand All @@ -325,7 +325,7 @@ func (h *Handler) handleDefault(w dns.ResponseWriter, req *dns.Msg) {
continue
}
if h.truncate {
logrus.Debugf("handleDefault truncating reply: %v", reply)
logrus.Tracef("handleDefault truncating reply: %v", reply)
reply.Truncate(truncateSize)
}
if err = w.WriteMsg(reply); err != nil {
Expand All @@ -337,7 +337,7 @@ func (h *Handler) handleDefault(w dns.ResponseWriter, req *dns.Msg) {
var reply dns.Msg
reply.SetReply(req)
if h.truncate {
logrus.Debugf("handleDefault truncating reply: %v", reply)
logrus.Tracef("handleDefault truncating reply: %v", reply)
reply.Truncate(truncateSize)
}
if err := w.WriteMsg(&reply); err != nil {
Expand Down

0 comments on commit f086bc4

Please sign in to comment.