api: Failed call retry with region only when http.StatusBadRequest.

Fixes https://github.com/minio/minio-go/issues/677
This commit is contained in:
Harshavardhana 2017-05-13 19:53:24 +02:00 committed by Alexander Neumann
parent 0249c16b04
commit c7209ef231
3 changed files with 8 additions and 6 deletions

View File

@ -89,7 +89,7 @@ func (c Client) MakeBucket(bucketName string, location string) (err error) {
if resp.StatusCode != http.StatusOK {
err := httpRespToErrorResponse(resp, bucketName, "")
errResp := ToErrorResponse(err)
if errResp.Code == "InvalidRegion" && errResp.Region != "" {
if resp.StatusCode == http.StatusBadRequest && errResp.Region != "" {
// Fetch bucket region found in headers
// of S3 error response, attempt bucket
// create again.

View File

@ -157,11 +157,13 @@ func hashCopyN(hashAlgorithms map[string]hash.Hash, hashSums map[string][]byte,
return 0, err
}
}
if err == nil && size == partSize {
for k, v := range hashAlgorithms {
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

View File

@ -553,7 +553,7 @@ func (c Client) executeMethod(method string, metadata requestMetadata) (res *htt
// Bucket region if set in error response and the error
// code dictates invalid region, we can retry the request
// with the new region.
if errResponse.Code == "InvalidRegion" && errResponse.Region != "" {
if res.StatusCode == http.StatusBadRequest && errResponse.Region != "" {
c.bucketLocCache.Set(metadata.bucketName, errResponse.Region)
continue // Retry.
}