middleware/kubernetes: fix aaaa response (#780)

* fix aaaa response

* unit tests
This commit is contained in:
Chris O'Haver 2017-07-20 08:19:29 -04:00 committed by John Belamaric
parent 81315b0b3b
commit 58006cf847
3 changed files with 25 additions and 8 deletions

View file

@ -57,7 +57,7 @@ func (k Kubernetes) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.M
path = strings.Join(dns.SplitDomainName(path)[1:], ".")
newstate := state.NewWithQuestion(strings.Join([]string{name, path}, "."), state.QType())
records, extra, _, err = k.routeRequest(zone, newstate)
if !k.IsNameError(err) {
if !k.IsNameError(err) && len(records) > 0 {
records = append(records, nil)
copy(records[1:], records)
records[0] = newCNAME(origQName, records[0].Header().Name, records[0].Header().Ttl)
@ -79,7 +79,7 @@ func (k Kubernetes) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.M
// Search . in this middleware
newstate := state.NewWithQuestion(strings.Join([]string{name, "."}, ""), state.QType())
records, extra, _, err = k.routeRequest(zone, newstate)
if !k.IsNameError(err) {
if !k.IsNameError(err) && len(records) > 0 {
records = append(records, nil)
copy(records[1:], records)
records[0] = newCNAME(origQName, records[0].Header().Name, records[0].Header().Ttl)