No retries if minio server is down/connection refused err (#11809)

This commit is contained in:
ebozduman 2021-03-18 11:05:48 -07:00 committed by GitHub
parent eed3b66d98
commit 32b088a2ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
}