plugin/forward: fix healthchecker crash (#2165)

This commit is contained in:
Ruslan Drozhdzh 2018-10-09 22:50:30 +03:00 committed by Miek Gieben
parent cbcc38bcb5
commit 298b860a97
3 changed files with 9 additions and 0 deletions

View file

@ -12,12 +12,15 @@ import (
"github.com/coredns/coredns/plugin"
"github.com/coredns/coredns/plugin/debug"
clog "github.com/coredns/coredns/plugin/pkg/log"
"github.com/coredns/coredns/request"
"github.com/miekg/dns"
ot "github.com/opentracing/opentracing-go"
)
var log = clog.NewWithPlugin("forward")
// Forward represents a plugin instance that can proxy requests to another (DNS) server. It has a list
// of proxies each representing one upstream proxy.
type Forward struct {

View file

@ -31,6 +31,7 @@ func NewHealthChecker(trans string) HealthChecker {
return &dnsHc{c: c}
}
log.Warningf("No healthchecker for transport %q", trans)
return nil
}

View file

@ -50,6 +50,11 @@ func (p *Proxy) SetExpire(expire time.Duration) { p.transport.SetExpire(expire)
// Healthcheck kicks of a round of health checks for this proxy.
func (p *Proxy) Healthcheck() {
if p.health == nil {
log.Warning("No healthchecker")
return
}
p.probe.Do(func() error {
return p.health.Check(p)
})