diff options
author | 2016-07-04 21:13:28 +0100 | |
---|---|---|
committer | 2016-07-04 21:13:28 +0100 | |
commit | 558c34a23e7aec736580c5585e7eceeff9220667 (patch) | |
tree | f726a613c95b6415ed78bc843d1f91b54f0da824 /middleware/proxy/policy.go | |
parent | 181ad851bc7a1485218a28cfeb383a80bf1e6e0e (diff) | |
download | coredns-558c34a23e7aec736580c5585e7eceeff9220667.tar.gz coredns-558c34a23e7aec736580c5585e7eceeff9220667.tar.zst coredns-558c34a23e7aec736580c5585e7eceeff9220667.zip |
middleware/proxy: healthchecks fixes (#183)
* middleware/proxy: add spray keyword
When spray is used, the proxy will, when all backend are down, spray to
each target. When not used, default to the old defaults: max 1 failure
and no spray. These defaults are also used when forwarding queries to
another CoreDNS instance.
Update the README with the new keyword.
* typos
* Make MaxFail = 1 again
* more reversals
Diffstat (limited to 'middleware/proxy/policy.go')
-rw-r--r-- | middleware/proxy/policy.go | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/middleware/proxy/policy.go b/middleware/proxy/policy.go index 077ecff33..e0c9d7e2b 100644 --- a/middleware/proxy/policy.go +++ b/middleware/proxy/policy.go @@ -1,6 +1,7 @@ package proxy import ( + "log" "math/rand" "sync/atomic" ) @@ -44,9 +45,6 @@ func (r *Random) Select(pool HostPool) *UpstreamHost { } } } - if randHost == nil { - return new(Spray).Select(pool) - } return randHost } @@ -58,6 +56,7 @@ type Spray struct{} func (r *Spray) Select(pool HostPool) *UpstreamHost { rnd := rand.Int() % len(pool) randHost := pool[rnd] + log.Printf("[WARNING] All hosts reported as down, spraying to target: %s", randHost.Name) return randHost } @@ -93,9 +92,6 @@ func (r *LeastConn) Select(pool HostPool) *UpstreamHost { } } } - if bestHost == nil { - return new(Spray).Select(pool) - } return bestHost } @@ -113,8 +109,5 @@ func (r *RoundRobin) Select(pool HostPool) *UpstreamHost { for i := uint32(1); host.Down() && i < poolLen; i++ { host = pool[(selection+i)%poolLen] } - if host.Down() { - return new(Spray).Select(pool) - } return host } |