From c0d067b7ee4ad937c13bf5c3c3a8b2228af22a8a Mon Sep 17 00:00:00 2001 From: Matt Jaffee Date: Fri, 21 Jun 2019 12:15:58 -0500 Subject: [PATCH] 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 {