Merge branch 'master' into master

This commit is contained in:
asvetlik 2019-06-24 12:13:52 -05:00 committed by GitHub
commit 9c5848daeb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1702,22 +1702,24 @@ func confirmNodeDown(uri URI, log logger.Logger) bool {
Host: uri.HostPort(),
Path: "version",
}
ctx, cancel := context.WithTimeout(context.Background(), confirmDownTimeout*time.Second)
defer cancel()
req, err := http.NewRequest("GET", u.String(), nil)
if err != nil {
log.Printf("bad request:%s %s", u.String(), err)
return false
}
for i := 0; i < confirmDownRetries; i++ {
ctx, cancel := context.WithTimeout(context.Background(), confirmDownTimeout*time.Second)
defer cancel()
resp, err := http.DefaultClient.Do(req.WithContext(ctx))
var bod []byte
if err == nil {
bod, err = ioutil.ReadAll(resp.Body)
if resp.StatusCode == 200 {
return false
}
}
log.Printf("NodeLeave Timeout with %s %d", uri.HostPort(), i)
log.Printf("NodeLeave confirm with %s %d. err: '%v' bod: '%s'", uri.HostPort(), i, err, bod)
time.Sleep(confirmDownSleep * time.Second)
}
return true