From 32b088a2ff3e5d63cf5170b4b1e4ab9c17a0edb2 Mon Sep 17 00:00:00 2001 From: ebozduman Date: Thu, 18 Mar 2021 11:05:48 -0700 Subject: [PATCH] No retries if minio server is down/connection refused err (#11809) --- pkg/madmin/api.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/madmin/api.go b/pkg/madmin/api.go index d34a43579..1747ff65f 100644 --- a/pkg/madmin/api.go +++ b/pkg/madmin/api.go @@ -34,6 +34,7 @@ import ( "regexp" "runtime" "strings" + "syscall" "time" "github.com/minio/minio-go/v7/pkg/credentials" @@ -340,7 +341,6 @@ var successStatus = []int{ // delayed manner using a standard back off algorithm. func (adm AdminClient) executeMethod(ctx context.Context, method string, reqData requestData) (res *http.Response, err error) { var reqRetry = MaxRetry // Indicates how many times we can retry the request - defer func() { if err != nil { // close idle connections before returning, upon error. @@ -365,6 +365,10 @@ func (adm AdminClient) executeMethod(ctx context.Context, method string, reqData // Initiate the request. res, err = adm.do(req) if err != nil { + // Give up right away if it is a connection refused problem + if errors.Is(err, syscall.ECONNREFUSED) { + return nil, err + } if err == context.Canceled || err == context.DeadlineExceeded { return nil, err }