api: Failed call retry with region only when http.StatusBadRequest.
Fixes https://github.com/minio/minio-go/issues/677
This commit is contained in:
parent
0249c16b04
commit
c7209ef231
3 changed files with 8 additions and 6 deletions
|
@ -89,7 +89,7 @@ func (c Client) MakeBucket(bucketName string, location string) (err error) {
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
err := httpRespToErrorResponse(resp, bucketName, "")
|
err := httpRespToErrorResponse(resp, bucketName, "")
|
||||||
errResp := ToErrorResponse(err)
|
errResp := ToErrorResponse(err)
|
||||||
if errResp.Code == "InvalidRegion" && errResp.Region != "" {
|
if resp.StatusCode == http.StatusBadRequest && errResp.Region != "" {
|
||||||
// Fetch bucket region found in headers
|
// Fetch bucket region found in headers
|
||||||
// of S3 error response, attempt bucket
|
// of S3 error response, attempt bucket
|
||||||
// create again.
|
// create again.
|
||||||
|
|
|
@ -157,11 +157,13 @@ func hashCopyN(hashAlgorithms map[string]hash.Hash, hashSums map[string][]byte,
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if err == nil && size == partSize {
|
||||||
for k, v := range hashAlgorithms {
|
for k, v := range hashAlgorithms {
|
||||||
hashSums[k] = v.Sum(nil)
|
hashSums[k] = v.Sum(nil)
|
||||||
}
|
}
|
||||||
return size, err
|
return size, nil
|
||||||
|
}
|
||||||
|
return 0, ErrUnexpectedEOF(size, partSize, "", "")
|
||||||
}
|
}
|
||||||
|
|
||||||
// getUploadID - fetch upload id if already present for an object name
|
// getUploadID - fetch upload id if already present for an object name
|
||||||
|
|
2
vendor/src/github.com/minio/minio-go/api.go
vendored
2
vendor/src/github.com/minio/minio-go/api.go
vendored
|
@ -553,7 +553,7 @@ func (c Client) executeMethod(method string, metadata requestMetadata) (res *htt
|
||||||
// Bucket region if set in error response and the error
|
// Bucket region if set in error response and the error
|
||||||
// code dictates invalid region, we can retry the request
|
// code dictates invalid region, we can retry the request
|
||||||
// with the new region.
|
// with the new region.
|
||||||
if errResponse.Code == "InvalidRegion" && errResponse.Region != "" {
|
if res.StatusCode == http.StatusBadRequest && errResponse.Region != "" {
|
||||||
c.bucketLocCache.Set(metadata.bucketName, errResponse.Region)
|
c.bucketLocCache.Set(metadata.bucketName, errResponse.Region)
|
||||||
continue // Retry.
|
continue // Retry.
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue