s3api: Better handle 503s in get_container_info, too

Change-Id: I269a59559a943fbf2781224d6962b25f6e07d30c
Related-Change: Iadb0a40092b8347eb5c04785cc14d1324cc9396f
This commit is contained in:
Tim Burke 2020-10-26 09:29:54 -07:00
parent a303e30fc4
commit 6af4449268
2 changed files with 6 additions and 3 deletions

View File

@ -1485,8 +1485,10 @@ class S3Request(swob.Request):
info = get_container_info(sw_req.environ, app, swift_source='S3')
if is_success(info['status']):
return info
elif info['status'] == 404:
elif info['status'] == HTTP_NOT_FOUND:
raise NoSuchBucket(self.container_name)
elif info['status'] == HTTP_SERVICE_UNAVAILABLE:
raise ServiceUnavailable()
else:
raise InternalError(
'unexpected status code %d' % info['status'])

View File

@ -31,7 +31,7 @@ from test.unit.common.middleware.s3api.test_s3api import S3ApiTestCase
from swift.common.middleware.s3api.s3request import S3Request, \
S3AclRequest, SigV4Request, SIGV4_X_AMZ_DATE_FORMAT, HashingInput
from swift.common.middleware.s3api.s3response import InvalidArgument, \
NoSuchBucket, InternalError, \
NoSuchBucket, InternalError, ServiceUnavailable, \
AccessDenied, SignatureDoesNotMatch, RequestTimeTooSkewed, BadDigest
from swift.common.utils import md5
@ -332,7 +332,8 @@ class TestRequest(S3ApiTestCase):
self.assertEqual(204, info['status']) # sanity
self.assertEqual(10, mock_info.call_count)
expected_errors = [(404, NoSuchBucket), (0, InternalError)]
expected_errors = [(404, NoSuchBucket), (0, InternalError),
(503, ServiceUnavailable)]
for status, expected_error in expected_errors:
with patch('swift.common.middleware.s3api.s3request.'
'get_container_info',