aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Ondřej Benkovský <ondrej.benkovsky@wandera.com> 2021-07-09 16:35:38 +0200
committerGravatar GitHub <noreply@github.com> 2021-07-09 16:35:38 +0200
commit2a61309cad794848e247e2d3de7369b96e12efd1 (patch)
tree28f473a82c4a7330c2589dae0b49ebb3666ca5b4
parent70b51a73d3a0029394dbdbc9f52a4d3d8e89d6f5 (diff)
downloadcoredns-2a61309cad794848e247e2d3de7369b96e12efd1.tar.gz
coredns-2a61309cad794848e247e2d3de7369b96e12efd1.tar.zst
coredns-2a61309cad794848e247e2d3de7369b96e12efd1.zip
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: Ondrej Benkovsky <ondrej.benkovsky@wandera.com> * fixup! when no response is written, fallback to status of next plugin in prometheus plugin Signed-off-by: Ondrej Benkovsky <ondrej.benkovsky@wandera.com>
-rw-r--r--plugin/metrics/handler.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/plugin/metrics/handler.go b/plugin/metrics/handler.go
index 0dbc053da..f26f90598 100644
--- a/plugin/metrics/handler.go
+++ b/plugin/metrics/handler.go
@@ -26,7 +26,14 @@ func (m *Metrics) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg
rw := dnstest.NewRecorder(w)
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
}