mirror of
https://github.com/coredns/coredns.git
synced 2025-11-02 02:03:13 -05:00
middleware/proxy: fix race; add Go 1.7 backward compatibility (#603)
* Fix race on backend health status update * Ensure test case is compatible on Go 1.7
This commit is contained in:
committed by
Miek Gieben
parent
dfc71df07d
commit
7dc431ada3
@@ -250,7 +250,9 @@ func (u *staticUpstream) healthCheck() {
|
||||
}
|
||||
|
||||
hostURL := "http://" + net.JoinHostPort(checkHostName, checkPort) + u.HealthCheck.Path
|
||||
host.Unhealthy = false
|
||||
|
||||
host.checkMu.Lock()
|
||||
defer host.checkMu.Unlock()
|
||||
|
||||
if r, err := http.Get(hostURL); err == nil {
|
||||
io.Copy(ioutil.Discard, r.Body)
|
||||
@@ -259,6 +261,8 @@ func (u *staticUpstream) healthCheck() {
|
||||
log.Printf("[WARNING] Health check URL %s returned HTTP code %d\n",
|
||||
hostURL, r.StatusCode)
|
||||
host.Unhealthy = true
|
||||
} else {
|
||||
host.Unhealthy = false
|
||||
}
|
||||
} else {
|
||||
log.Printf("[WARNING] Health check probe failed: %v\n", err)
|
||||
|
||||
Reference in New Issue
Block a user