Return HTTPServerError instead of HTTPNotFound
Swift allows autocreate account. It should be treat as server error instead of 404 when it fails to create account Change-Id: I726271bc06e3c1b07a4af504c3fd7ddb789bd512 Closes-bug: 1718810
This commit is contained in:
parent
8ce5dd54e6
commit
5cbd5cf303
|
@ -1839,9 +1839,11 @@ class Controller(object):
|
|||
if is_success(resp.status_int):
|
||||
self.app.logger.info(_('autocreate account %r'), path)
|
||||
clear_info_cache(self.app, req.environ, account)
|
||||
return True
|
||||
else:
|
||||
self.app.logger.warning(_('Could not autocreate account %r'),
|
||||
path)
|
||||
return False
|
||||
|
||||
def GETorHEAD_base(self, req, server_type, node_iter, partition, path,
|
||||
concurrency=1, client_chunk_size=None):
|
||||
|
|
|
@ -24,7 +24,7 @@ from swift.proxy.controllers.base import Controller, delay_denial, \
|
|||
cors_validation, set_info_cache, clear_info_cache
|
||||
from swift.common.storage_policy import POLICIES
|
||||
from swift.common.swob import HTTPBadRequest, HTTPForbidden, \
|
||||
HTTPNotFound
|
||||
HTTPNotFound, HTTPServerError
|
||||
|
||||
|
||||
class ContainerController(Controller):
|
||||
|
@ -160,7 +160,8 @@ class ContainerController(Controller):
|
|||
account_partition, accounts, container_count = \
|
||||
self.account_info(self.account_name, req)
|
||||
if not accounts and self.app.account_autocreate:
|
||||
self.autocreate_account(req, self.account_name)
|
||||
if not self.autocreate_account(req, self.account_name):
|
||||
return HTTPServerError(request=req)
|
||||
account_partition, accounts, container_count = \
|
||||
self.account_info(self.account_name, req)
|
||||
if not accounts:
|
||||
|
|
|
@ -7782,7 +7782,7 @@ class TestContainerController(unittest.TestCase):
|
|||
# fail to retrieve account info
|
||||
test_status_map(
|
||||
(503, 503, 503), # account_info fails on 503
|
||||
404, missing_container=True)
|
||||
500, missing_container=True)
|
||||
# account fail after creation
|
||||
test_status_map(
|
||||
(404, 404, 404, # account_info fails on 404
|
||||
|
@ -7793,7 +7793,7 @@ class TestContainerController(unittest.TestCase):
|
|||
(503, 503, 404, # account_info fails on 404
|
||||
503, 503, 503, # PUT account
|
||||
503, 503, 404), # account_info fail
|
||||
404, missing_container=True)
|
||||
500, missing_container=True)
|
||||
# put fails
|
||||
test_status_map(
|
||||
(404, 404, 404, # account_info fails on 404
|
||||
|
|
Loading…
Reference in New Issue