Commit 2a61309c authored by Ondřej Benkovský's avatar Ondřej Benkovský Committed by GitHub

when no response is written, fallback to status of next plugin in prometheus plugin (#4727)

* when no response is written, fallback to status of next plugin in prometheus plugin
Signed-off-by: default avatarOndrej Benkovsky <ondrej.benkovsky@wandera.com>

* fixup! when no response is written, fallback to status of next plugin in prometheus plugin
Signed-off-by: default avatarOndrej Benkovsky <ondrej.benkovsky@wandera.com>
parent 70b51a73
...@@ -26,7 +26,14 @@ func (m *Metrics) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg ...@@ -26,7 +26,14 @@ func (m *Metrics) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg
rw := dnstest.NewRecorder(w) rw := dnstest.NewRecorder(w)
status, err := plugin.NextOrFailure(m.Name(), m.Next, ctx, rw, r) status, err := plugin.NextOrFailure(m.Name(), m.Next, ctx, rw, r)
vars.Report(WithServer(ctx), state, zone, rcode.ToString(rw.Rcode), rw.Len, rw.Start) rc := rw.Rcode
if !plugin.ClientWrite(status) {
// when no response was written, fallback to status returned from next plugin as this status
// is actually used as rcode of DNS response
// see https://github.com/coredns/coredns/blob/master/core/dnsserver/server.go#L318
rc = status
}
vars.Report(WithServer(ctx), state, zone, rcode.ToString(rc), rw.Len, rw.Start)
return status, err return status, err
} }
......
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