From 91be771dfb0d41a709120c95a258bb22c66f87af Mon Sep 17 00:00:00 2001 From: Aditya Manthramurthy Date: Tue, 11 Jun 2019 13:40:48 -0700 Subject: [PATCH] Retry on AccessDenied only in restricted cases (#1121) List buckets should be retried on an AccessDenied error only if the region in the reponse is only different from the region in the request just made. --- api.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/api.go b/api.go index 9acc59d6d0..f0719f2d70 100644 --- a/api.go +++ b/api.go @@ -668,8 +668,15 @@ func (c Client) executeMethod(ctx context.Context, method string, metadata reque } } else { // Most probably for ListBuckets() - metadata.bucketLocation = errResponse.Region - continue // Retry + if errResponse.Region != metadata.bucketLocation { + // Retry if the error + // response has a + // different region + // than the request we + // just made. + metadata.bucketLocation = errResponse.Region + continue // Retry + } } } }