mirror of
https://github.com/coredns/coredns.git
synced 2025-12-09 03:45:11 -05:00
healhcheck: various cleanups (#1106)
* healhcheck: various cleanups Network wasn't used. IgnorePaths wasn't used. Move checkdown function to common function shared between proxy protocols. And some naming fixed. Also reset the Fails on a succesful healthcheck back to 0. remove newlines from log * compile * fix test
This commit is contained in:
@@ -40,28 +40,7 @@ func NewLookupWithOption(hosts []string, opts Options) Proxy {
|
||||
Conns: 0,
|
||||
Fails: 0,
|
||||
FailTimeout: upstream.FailTimeout,
|
||||
|
||||
CheckDown: func(upstream *staticUpstream) healthcheck.UpstreamHostDownFunc {
|
||||
return func(uh *healthcheck.UpstreamHost) bool {
|
||||
|
||||
down := false
|
||||
|
||||
uh.CheckMu.Lock()
|
||||
until := uh.OkUntil
|
||||
uh.CheckMu.Unlock()
|
||||
|
||||
if !until.IsZero() && time.Now().After(until) {
|
||||
down = true
|
||||
}
|
||||
|
||||
fails := atomic.LoadInt32(&uh.Fails)
|
||||
if fails >= upstream.MaxFails && upstream.MaxFails != 0 {
|
||||
down = true
|
||||
}
|
||||
return down
|
||||
}
|
||||
}(upstream),
|
||||
WithoutPathPrefix: upstream.WithoutPathPrefix,
|
||||
CheckDown: checkDownFunc(upstream),
|
||||
}
|
||||
|
||||
upstream.Hosts[i] = uh
|
||||
|
||||
Reference in New Issue
Block a user