Add more logging

Put some more logging in CoreDNS.
This commit is contained in:
Miek Gieben 2016-04-05 07:37:05 +01:00
parent 4c55b6732f
commit 20e16491ec
8 changed files with 24 additions and 14 deletions

View file

@ -83,7 +83,6 @@ func (e Etcd) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (i
m.Ns = []dns.RR{e.SOA(zone, state)}
state.W.WriteMsg(m)
return dns.RcodeSuccess, nil
}
if len(records) > 0 {
m.Answer = append(m.Answer, records...)

View file

@ -73,7 +73,7 @@ func (e Etcd) A(zone string, state middleware.State, previousRecords []dns.RR) (
case ip.To4() != nil:
records = append(records, serv.NewA(state.QName(), ip.To4()))
case ip.To4() == nil:
// noda?
// nodata?
}
}
return records, nil

View file

@ -2,6 +2,7 @@ package file
import (
"fmt"
"log"
"github.com/miekg/coredns/middleware"
@ -21,9 +22,12 @@ func notify(zone string, to []string) error {
m.SetNotify(zone)
c := new(dns.Client)
// TODO(miek): error handling? Run this in a goroutine?
for _, t := range to {
notifyAddr(c, m, t)
if err := notifyAddr(c, m, t); err != nil {
log.Printf("[ERROR] " + err.Error())
} else {
log.Printf("[INFO] Sent notify for zone %s to %s", zone, t)
}
}
return nil
}
@ -34,7 +38,6 @@ func notifyAddr(c *dns.Client, m *dns.Msg, s string) error {
if err == nil && ret.Rcode == dns.RcodeSuccess || ret.Rcode == dns.RcodeNotImplemented {
return nil
}
// timeout? mean don't want it. should stop sending as well?
}
return fmt.Errorf("failed to send notify for zone '%s' to '%s'", m.Question[0].Name, s)
return fmt.Errorf("Failed to send notify for zone '%s' to '%s'", m.Question[0].Name, s)
}

View file

@ -20,13 +20,13 @@ Transfer:
for _, tr := range z.TransferFrom {
c, err := t.In(m, tr)
if err != nil {
log.Printf("[ERROR] failed to setup transfer %s with %s: %v", z.name, z.TransferFrom[0], err)
log.Printf("[ERROR] Failed to setup transfer %s with %s: %v", z.name, z.TransferFrom[0], err)
Err = err
continue Transfer
}
for env := range c {
if env.Error != nil {
log.Printf("[ERROR] failed to parse transfer %s: %v", z.name, env.Error)
log.Printf("[ERROR] Failed to parse transfer %s: %v", z.name, env.Error)
Err = env.Error
continue Transfer
}
@ -44,6 +44,9 @@ Transfer:
}
}
}
if Err != nil {
log.Printf("[ERROR] Failed to transfer %s", z.name)
}
return nil
return Err // ignore errors for now. TODO(miek)
}

View file

@ -22,10 +22,10 @@ func (x Xfr) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (in
return dns.RcodeServerFailure, nil
}
if state.QType() != dns.TypeAXFR {
return 0, fmt.Errorf("file: xfr called with non transfer type: %d", state.QType())
return 0, fmt.Errorf("xfr called with non transfer type: %d", state.QType())
}
if state.Proto() == "udp" {
return 0, fmt.Errorf("file: xfr called with udp")
return 0, fmt.Errorf("xfr called with udp")
}
records := x.All()
@ -57,5 +57,4 @@ func (x Xfr) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (in
return dns.RcodeSuccess, nil
}
//const transferLength = 10e3 // Start a new envelop after message reaches this size.
const transferLength = 100 // Start a new envelop after message reaches this size.
const transferLength = 100 // Start a new envelop after message reaches this size. Intentionally small to test multi envelope parsing

View file

@ -38,6 +38,7 @@ func (z *Zone) TransferAllowed(state middleware.State) bool {
return true
}
}
// TODO(miek): future matching against IP/CIDR notations
return false
}

View file

@ -1,6 +1,10 @@
package loadbalance
import "github.com/miekg/dns"
import (
"log"
"github.com/miekg/dns"
)
type RoundRobinResponseWriter struct {
dns.ResponseWriter
@ -16,6 +20,7 @@ func (r *RoundRobinResponseWriter) WriteMsg(res *dns.Msg) error {
}
res.Answer = roundRobin(res.Answer)
res.Ns = roundRobin(res.Ns)
res.Extra = roundRobin(res.Extra)
return r.ResponseWriter.WriteMsg(res)
@ -61,6 +66,7 @@ func roundRobin(in []dns.RR) []dns.RR {
// Should we pack and unpack here to fiddle with the packet... Not likely.
func (r *RoundRobinResponseWriter) Write(buf []byte) (int, error) {
log.Printf("[WARNING] RoundRobin called with Write: no shuffling records")
n, err := r.ResponseWriter.Write(buf)
return n, err
}

View file

@ -29,5 +29,4 @@ func (z Zones) FullyQualify() {
for i, _ := range z {
z[i] = dns.Fqdn(z[i])
}
}