Commit 298b860a authored by Ruslan Drozhdzh's avatar Ruslan Drozhdzh Committed by Miek Gieben

plugin/forward: fix healthchecker crash (#2165)

parent cbcc38bc
...@@ -12,12 +12,15 @@ import ( ...@@ -12,12 +12,15 @@ import (
"github.com/coredns/coredns/plugin" "github.com/coredns/coredns/plugin"
"github.com/coredns/coredns/plugin/debug" "github.com/coredns/coredns/plugin/debug"
clog "github.com/coredns/coredns/plugin/pkg/log"
"github.com/coredns/coredns/request" "github.com/coredns/coredns/request"
"github.com/miekg/dns" "github.com/miekg/dns"
ot "github.com/opentracing/opentracing-go" 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 // Forward represents a plugin instance that can proxy requests to another (DNS) server. It has a list
// of proxies each representing one upstream proxy. // of proxies each representing one upstream proxy.
type Forward struct { type Forward struct {
......
...@@ -31,6 +31,7 @@ func NewHealthChecker(trans string) HealthChecker { ...@@ -31,6 +31,7 @@ func NewHealthChecker(trans string) HealthChecker {
return &dnsHc{c: c} return &dnsHc{c: c}
} }
log.Warningf("No healthchecker for transport %q", trans)
return nil return nil
} }
......
...@@ -50,6 +50,11 @@ func (p *Proxy) SetExpire(expire time.Duration) { p.transport.SetExpire(expire) ...@@ -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. // Healthcheck kicks of a round of health checks for this proxy.
func (p *Proxy) Healthcheck() { func (p *Proxy) Healthcheck() {
if p.health == nil {
log.Warning("No healthchecker")
return
}
p.probe.Do(func() error { p.probe.Do(func() error {
return p.health.Check(p) return p.health.Check(p)
}) })
......
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