Fix the status code of over quota response

Server will response 403 instead of 500 when quota exceeded.

Change-Id: I3cd26929c2a4b1011bea957d59481409e48403de
Closes-Bug: #1799110
This commit is contained in:
Hongbin Lu 2018-10-22 03:15:28 +00:00
parent c90642c4b2
commit 4b0cf9aae2
2 changed files with 2 additions and 6 deletions

View File

@ -470,12 +470,7 @@ class ContainersController(base.Controller):
except TypeError as e:
raise e
check_kwargs[res_name] = total
try:
QUOTAS.limit_check(context, project_id, **check_kwargs)
except exception.OverQuota as exc:
# Set HTTP response status code
pecan.response.status = 403
raise exc
QUOTAS.limit_check(context, project_id, **check_kwargs)
_check_deltas(context, deltas)

View File

@ -707,6 +707,7 @@ class ServerNotUsable(ZunException):
class OverQuota(ZunException):
message = _("Quota exceeded for resources: %(overs)s")
code = 403
class QuotaNotFound(NotFound):