plugin/autopath: Add metrics and remove log line (#1143)

* plugin/autopath: Add namespace selector and metrics

Add a namespace, so autopathing only is performed in this namespace.
This will make caching work for the cluster again.

Also export metrics that we've done a successful autopath

* dont shadow

* Fix

* Back the namespacing changes
This commit is contained in:
Miek Gieben
2017-10-15 19:39:24 +02:00
committed by GitHub
parent e34e2c251f
commit 70ee39844e
4 changed files with 41 additions and 6 deletions

View File

@@ -32,8 +32,6 @@ func (m Plugins ) AutoPath(state request.Request) []string {
package autopath
import (
"log"
"github.com/coredns/coredns/plugin"
"github.com/coredns/coredns/plugin/pkg/dnsutil"
"github.com/coredns/coredns/plugin/pkg/nonwriter"
@@ -76,7 +74,6 @@ func (a *AutoPath) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Ms
}
if len(searchpath) == 0 {
log.Printf("[WARNING] No search path available for autopath")
return plugin.NextOrFailure(a.Name(), a.Next, ctx, w, r)
}
@@ -87,7 +84,7 @@ func (a *AutoPath) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Ms
origQName := state.QName()
// Establish base name of the query. I.e what was originally asked.
base, err := dnsutil.TrimZone(state.QName(), searchpath[0]) // TODO(miek): we loose the original case of the query here.
base, err := dnsutil.TrimZone(state.QName(), searchpath[0])
if err != nil {
return dns.RcodeServerFailure, err
}
@@ -128,6 +125,7 @@ func (a *AutoPath) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Ms
// Write whatever non-nxdomain answer we've found.
w.WriteMsg(msg)
AutoPathCount.WithLabelValues().Add(1)
return rcode, err
}