fix: Quit when the context is canceled in madmin (#9264)

This commit is contained in:
Harshavardhana
2020-04-06 17:50:14 -07:00
committed by GitHub
parent 91f21ddc47
commit 928f5b0564
2 changed files with 17 additions and 7 deletions

View File

@@ -367,12 +367,11 @@ func (adm AdminClient) executeMethod(ctx context.Context, method string, reqData
// Initiate the request.
res, err = adm.do(req)
if err != nil {
// For supported http requests errors verify.
if isHTTPReqErrorRetryable(err) {
continue // Retry.
if err == context.Canceled || err == context.DeadlineExceeded {
return nil, err
}
// For other errors, return here no need to retry.
return nil, err
// retry all network errors.
continue
}
// For any known successful http status, return quickly.
@@ -413,6 +412,12 @@ func (adm AdminClient) executeMethod(ctx context.Context, method string, reqData
break
}
// Return an error when retry is canceled or deadlined
if e := retryCtx.Err(); e != nil {
return nil, e
}
return res, err
}