aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorGravatar Carl-Magnus Björkell <cmb@tradeshift.com> 2018-10-31 22:08:58 +0100
committerGravatar Miek Gieben <miek@miek.nl> 2018-10-31 21:08:58 +0000
commitcfbfa5c00e6be3f1dceabe33078499e332de58ff (patch)
tree393d75dbf1115b2cd919f4189c290191a063d349 /plugin
parent1ef0a02b467ac234b9f99ed3060d31ff6a2ca546 (diff)
downloadcoredns-cfbfa5c00e6be3f1dceabe33078499e332de58ff.tar.gz
coredns-cfbfa5c00e6be3f1dceabe33078499e332de58ff.tar.zst
coredns-cfbfa5c00e6be3f1dceabe33078499e332de58ff.zip
plugin/etcd: propagate recursion flag properly (#2254)
When fetching records via the etcd plugin, the recursion flag was never set properly according to if the caller requested an exact record match or not. This cause problems especially in CNAME lookups, where recursion took place and a random RR was returned instead of the one that was specifically added for this key. Even when there is no service attached on the given path, it is still wrong to return a random one from the recursion. Fixing by using the `exact` flag to decide if recursion should be done.
Diffstat (limited to 'plugin')
-rw-r--r--plugin/etcd/cname_test.go7
-rw-r--r--plugin/etcd/etcd.go2
2 files changed, 8 insertions, 1 deletions
diff --git a/plugin/etcd/cname_test.go b/plugin/etcd/cname_test.go
index bf27573cc..48766c793 100644
--- a/plugin/etcd/cname_test.go
+++ b/plugin/etcd/cname_test.go
@@ -57,6 +57,7 @@ var servicesCname = []*msg.Service{
{Host: "cname5.region2.skydns.test", Key: "cname4.region2.skydns.test."},
{Host: "cname6.region2.skydns.test", Key: "cname5.region2.skydns.test."},
{Host: "endpoint.region2.skydns.test", Key: "cname6.region2.skydns.test."},
+ {Host: "mainendpoint.region2.skydns.test", Key: "region2.skydns.test."},
{Host: "10.240.0.1", Key: "endpoint.region2.skydns.test."},
}
@@ -76,4 +77,10 @@ var dnsTestCasesCname = []test.Case{
test.A("endpoint.region2.skydns.test. 300 IN A 10.240.0.1"),
},
},
+ {
+ Qname: "region2.skydns.test.", Qtype: dns.TypeCNAME,
+ Answer: []dns.RR{
+ test.CNAME("region2.skydns.test. 300 IN CNAME mainendpoint.region2.skydns.test."),
+ },
+ },
}
diff --git a/plugin/etcd/etcd.go b/plugin/etcd/etcd.go
index 493764f0b..5d258507c 100644
--- a/plugin/etcd/etcd.go
+++ b/plugin/etcd/etcd.go
@@ -75,7 +75,7 @@ func (e *Etcd) Records(state request.Request, exact bool) ([]msg.Service, error)
name := state.Name()
path, star := msg.PathWithWildcard(name, e.PathPrefix)
- r, err := e.get(path, true)
+ r, err := e.get(path, !exact)
if err != nil {
return nil, err
}