Merge "Return HTTPServerError instead of HTTPNotFound"

This commit is contained in:
Zuul 2018-01-19 03:26:14 +00:00 committed by Gerrit Code Review
commit 0cf032a75f
3 changed files with 7 additions and 4 deletions
swift/proxy/controllers
test/unit/proxy

@ -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:

@ -7825,7 +7825,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
@ -7836,7 +7836,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