From 481c85acae6dc3d3bdae92410a47a1d86d57c410 Mon Sep 17 00:00:00 2001 From: Matt Jaffee Date: Thu, 20 Jun 2019 17:32:57 -0500 Subject: [PATCH 1/2] more info if nodeleave confirmation queries fail --- cluster.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cluster.go b/cluster.go index cf0090c0f..4c32f6b42 100644 --- a/cluster.go +++ b/cluster.go @@ -1709,15 +1709,17 @@ func confirmNodeDown(uri URI, log logger.Logger) bool { log.Printf("bad request:%s %s", u.String(), err) return false } - for i := 0; i < confirmDownRetries; i++ { 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 From c0d067b7ee4ad937c13bf5c3c3a8b2228af22a8a Mon Sep 17 00:00:00 2001 From: Matt Jaffee Date: Fri, 21 Jun 2019 12:15:58 -0500 Subject: [PATCH 2/2] move context timeout inside loop, so context gets a fresh deadline --- cluster.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cluster.go b/cluster.go index 4c32f6b42..c972daadd 100644 --- a/cluster.go +++ b/cluster.go @@ -1702,14 +1702,14 @@ 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 {