Merge "Fix best response to return correct status"

This commit is contained in:
Jenkins 2015-04-16 19:22:22 +00:00 committed by Gerrit Code Review
commit f90fe4fb3d
2 changed files with 3 additions and 4 deletions

View File

@ -49,7 +49,7 @@ from swift.common.http import is_informational, is_success, is_redirection, \
HTTP_BAD_REQUEST, HTTP_NOT_FOUND, HTTP_SERVICE_UNAVAILABLE, \
HTTP_INSUFFICIENT_STORAGE, HTTP_UNAUTHORIZED, HTTP_CONTINUE
from swift.common.swob import Request, Response, HeaderKeyDict, Range, \
HTTPException, HTTPRequestedRangeNotSatisfiable
HTTPException, HTTPRequestedRangeNotSatisfiable, HTTPServiceUnavailable
from swift.common.request_helpers import strip_sys_meta_prefix, \
strip_user_meta_prefix, is_user_meta, is_sys_meta, is_sys_or_user_meta
from swift.common.storage_policy import POLICIES
@ -1256,10 +1256,9 @@ class Controller(object):
quorum_size=quorum_size)
if not resp:
resp = Response(request=req)
resp = HTTPServiceUnavailable(request=req)
self.app.logger.error(_('%(type)s returning 503 for %(statuses)s'),
{'type': server_type, 'statuses': statuses})
resp.status = '503 Internal Server Error'
return resp

View File

@ -579,7 +579,7 @@ class TestFuncs(unittest.TestCase):
overrides = {302: 204, 100: 204}
resp = base.best_response(req, statuses, reasons, bodies, server_type,
headers=headers, overrides=overrides)
self.assertEqual(resp.status, '503 Internal Server Error')
self.assertEqual(resp.status, '503 Service Unavailable')
# next make a 404 quorum and make sure the last delete (real) 404
# status is the one returned.