Commit 3b7b9b49 authored by Miek Gieben's avatar Miek Gieben Committed by GitHub

Fix lookup test (#206)

* Always continue

* debug queries: more sane impl

This PR just add a msg.Service to debug instead of crafting an TXT RR
at that point. This way we lift on the normal way of generating debug
responses and don't muck with that implementation.

The tags=etcd is flaky as hell for some reason.
parent b53661d2
...@@ -113,18 +113,20 @@ process in the response. The general form looks like this: ...@@ -113,18 +113,20 @@ process in the response. The general form looks like this:
skydns.test.skydns.dom.a. 300 CH TXT "127.0.0.1:0(10,0,,false)[0,]" skydns.test.skydns.dom.a. 300 CH TXT "127.0.0.1:0(10,0,,false)[0,]"
This shows the complete key as the owername, the rdata of the TXT record has: This shows the complete key as the owername, the rdata of the TXT record has:
`host:port(priority,weight,txt content,mail)[targetstrip,group]`. `host:port(priority,weight,txt content,mail)[targetstrip,group]`.
Any errors seen doing parsing will show up like this: Errors when communicating with an upstream will be returned as: `host:0(0,0,error message,false)[0,]`.
. 0 CH TXT "/skydns/local/skydns/r/a: invalid character '.' after object key:value pair" An example:
www.example.org. 0 CH TXT "www.example.org.:0(0,0, IN A: unreachable backend,false)[0,]"
which shows `a.r.skydns.local.` has a json encoding problem. Signalling that an A record for www.example.org. was sought, but it failed with that error.
Errors when communicating with an upstream will be returned as: Any errors seen doing parsing will show up like this:
. 0 CH TXT "/skydns/local/skydns/r/a: invalid character '.' after object key:value pair"
. 0 CH TXT "example.org. IN A: unreachable backend" which shows `a.r.skydns.local.` has a json encoding problem.
Signalling that an A record for example.org. was sought, but it failed
with that error.
...@@ -24,7 +24,7 @@ type Etcd struct { ...@@ -24,7 +24,7 @@ type Etcd struct {
Client etcdc.KeysAPI Client etcdc.KeysAPI
Ctx context.Context Ctx context.Context
Inflight *singleflight.Group Inflight *singleflight.Group
Stubmap *map[string]proxy.Proxy // List of proxies for stub resolving. Stubmap *map[string]proxy.Proxy // list of proxies for stub resolving.
Debug bool // Do we allow debug queries. Debug bool // Do we allow debug queries.
} }
......
package etcd package etcd
import ( import (
"errors"
"fmt" "fmt"
"math" "math"
"net" "net"
...@@ -74,11 +73,9 @@ func (e Etcd) A(zone string, state middleware.State, previousRecords []dns.RR, o ...@@ -74,11 +73,9 @@ func (e Etcd) A(zone string, state middleware.State, previousRecords []dns.RR, o
} }
m1, e1 := e.Proxy.Lookup(state, target, state.QType()) m1, e1 := e.Proxy.Lookup(state, target, state.QType())
if e1 != nil { if e1 != nil {
if opt.Debug != "" { debugMsg := msg.Service{Key: msg.Path(target, e.PathPrefix), Host: target, Text: " IN " + state.Type() + ": " + e1.Error()}
debugTxt := errorToTxt(errors.New(target + " IN " + state.Type() + ":" + e1.Error())) debug = append(debug, debugMsg)
records = append(records, debugTxt) continue
continue
}
} }
// Len(m1.Answer) > 0 here is well? // Len(m1.Answer) > 0 here is well?
records = append(records, newRecord) records = append(records, newRecord)
...@@ -138,8 +135,8 @@ func (e Etcd) AAAA(zone string, state middleware.State, previousRecords []dns.RR ...@@ -138,8 +135,8 @@ func (e Etcd) AAAA(zone string, state middleware.State, previousRecords []dns.RR
} }
m1, e1 := e.Proxy.Lookup(state, target, state.QType()) m1, e1 := e.Proxy.Lookup(state, target, state.QType())
if e1 != nil { if e1 != nil {
debugTxt := errorToTxt(errors.New(target + " IN " + state.Type() + ": " + e1.Error())) debugMsg := msg.Service{Key: msg.Path(target, e.PathPrefix), Host: target, Text: " IN " + state.Type() + ": " + e1.Error()}
records = append(records, debugTxt) debug = append(debug, debugMsg)
continue continue
} }
// Len(m1.Answer) > 0 here is well? // Len(m1.Answer) > 0 here is well?
...@@ -203,8 +200,8 @@ func (e Etcd) SRV(zone string, state middleware.State, opt Options) (records, ex ...@@ -203,8 +200,8 @@ func (e Etcd) SRV(zone string, state middleware.State, opt Options) (records, ex
if e1 == nil { if e1 == nil {
extra = append(extra, m1.Answer...) extra = append(extra, m1.Answer...)
} else { } else {
debugTxt := errorToTxt(errors.New(srv.Target + " IN A: " + e1.Error())) debugMsg := msg.Service{Key: msg.Path(srv.Target, e.PathPrefix), Host: srv.Target, Text: " IN A: " + e1.Error()}
extra = append(extra, debugTxt) debug = append(debug, debugMsg)
} }
m1, e1 = e.Proxy.Lookup(state, srv.Target, dns.TypeAAAA) m1, e1 = e.Proxy.Lookup(state, srv.Target, dns.TypeAAAA)
...@@ -216,8 +213,8 @@ func (e Etcd) SRV(zone string, state middleware.State, opt Options) (records, ex ...@@ -216,8 +213,8 @@ func (e Etcd) SRV(zone string, state middleware.State, opt Options) (records, ex
} }
} }
} else { } else {
debugTxt := errorToTxt(errors.New(srv.Target + " IN AAAA: " + e1.Error())) debugMsg := msg.Service{Key: msg.Path(srv.Target, e.PathPrefix), Host: srv.Target, Text: " IN AAAA: " + e1.Error()}
extra = append(extra, debugTxt) debug = append(debug, debugMsg)
} }
break break
} }
...@@ -276,8 +273,8 @@ func (e Etcd) MX(zone string, state middleware.State, opt Options) (records, ext ...@@ -276,8 +273,8 @@ func (e Etcd) MX(zone string, state middleware.State, opt Options) (records, ext
if e1 == nil { if e1 == nil {
extra = append(extra, m1.Answer...) extra = append(extra, m1.Answer...)
} else { } else {
debugTxt := errorToTxt(errors.New(mx.Mx + " IN A: " + e1.Error())) debugMsg := msg.Service{Key: msg.Path(mx.Mx, e.PathPrefix), Host: mx.Mx, Text: " IN A: " + e1.Error()}
extra = append(extra, debugTxt) debug = append(debug, debugMsg)
} }
m1, e1 = e.Proxy.Lookup(state, mx.Mx, dns.TypeAAAA) m1, e1 = e.Proxy.Lookup(state, mx.Mx, dns.TypeAAAA)
if e1 == nil { if e1 == nil {
...@@ -288,8 +285,8 @@ func (e Etcd) MX(zone string, state middleware.State, opt Options) (records, ext ...@@ -288,8 +285,8 @@ func (e Etcd) MX(zone string, state middleware.State, opt Options) (records, ext
} }
} }
} else { } else {
debugTxt := errorToTxt(errors.New(mx.Mx + " IN AAAA: " + e1.Error())) debugMsg := msg.Service{Key: msg.Path(mx.Mx, e.PathPrefix), Host: mx.Mx, Text: " IN AAAA: " + e1.Error()}
extra = append(extra, debugTxt) debug = append(debug, debugMsg)
} }
break break
} }
......
...@@ -22,10 +22,10 @@ func TestProxyLookupFailDebug(t *testing.T) { ...@@ -22,10 +22,10 @@ func TestProxyLookupFailDebug(t *testing.T) {
prxy := etc.Proxy prxy := etc.Proxy
etc.Proxy = proxy.New([]string{"127.0.0.0:154"}) etc.Proxy = proxy.New([]string{"127.0.0.0:154"})
etc.Debug = true defer func() { etc.Proxy = prxy }()
etc.Debug = true
defer func() { etc.Debug = false }() defer func() { etc.Debug = false }()
defer func() { etc.Proxy = prxy }()
for _, tc := range dnsTestCasesProxy { for _, tc := range dnsTestCasesProxy {
m := tc.Msg() m := tc.Msg()
...@@ -58,20 +58,20 @@ func TestProxyLookupFailDebug(t *testing.T) { ...@@ -58,20 +58,20 @@ func TestProxyLookupFailDebug(t *testing.T) {
} }
} }
// Note the key is encoded as DNS name, while in "reality" it is a etcd path.
var servicesProxy = []*msg.Service{ var servicesProxy = []*msg.Service{
{Host: "www.example.org", Key: "a.dom.skydns.test."}, {Host: "www.example.org", Key: "a.dom.skydns.test."},
} }
var dnsTestCasesProxy = []test.Case{ var dnsTestCasesProxy = []test.Case{
{ {
Qname: "dom.skydns.test.", Qtype: dns.TypeSRV, Qname: "o-o.debug.dom.skydns.test.", Qtype: dns.TypeSRV,
Answer: []dns.RR{ Answer: []dns.RR{
test.SRV("dom.skydns.test. 300 IN SRV 10 100 0 www.example.org."), test.SRV("dom.skydns.test. 300 IN SRV 10 100 0 www.example.org."),
}, },
Extra: []dns.RR{ Extra: []dns.RR{
test.TXT(". 0 CH TXT \"www.example.org. IN A: unreachable backend\""), test.TXT("a.dom.skydns.test. 300 CH TXT \"www.example.org:0(10,0,,false)[0,]\""),
test.TXT(". 0 CH TXT \"www.example.org. IN AAAA: unreachable backend\""), test.TXT("www.example.org. 0 CH TXT \"www.example.org.:0(0,0, IN A: unreachable backend,false)[0,]\""),
test.TXT("www.example.org. 0 CH TXT \"www.example.org.:0(0,0, IN AAAA: unreachable backend,false)[0,]\""),
}, },
}, },
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment