Adds a clear error message to operator-set limits
When an operator sets a limit that is greater than 2147483647, an explicit error message "Quota limit should not exceed 2147483647" is communicated. This is better than the initial error message which was "ERROR: The server has either erred or is incapable of performing the requested operation. (HTTP 500)." Closes-Bug: #1908352 Change-Id: I0d301c5f527c3e16e14021b679c85bd51833a1d6
This commit is contained in:
parent
329e8528e1
commit
daf7b3aacf
manila
db/sqlalchemy
tests/api/v2
@ -678,7 +678,13 @@ def quota_create(context, project_id, resource, limit, user_id=None,
|
||||
quota_ref.hard_limit = limit
|
||||
session = get_session()
|
||||
with session.begin():
|
||||
quota_ref.save(session)
|
||||
try:
|
||||
quota_ref.save(session)
|
||||
except Exception as e:
|
||||
if "out of range" in str(e).lower():
|
||||
msg = _("Quota limit should not exceed 2147483647")
|
||||
raise exception.InvalidInput(reason=msg)
|
||||
raise
|
||||
return quota_ref
|
||||
|
||||
|
||||
|
7
manila/db/sqlalchemy/releasenotes/notes/bug-1908352-add-explicit-error-message-c33c7b75a7e49257.yaml
Normal file
7
manila/db/sqlalchemy/releasenotes/notes/bug-1908352-add-explicit-error-message-c33c7b75a7e49257.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
When a quota value greater than 2147483647 is set, the error
|
||||
message "ERROR: Invalid input received:Quota limit should not
|
||||
exceed 2147483647. (HTTP 400)" is communicated to the user.
|
||||
|
@ -447,6 +447,30 @@ class QuotaSetsControllerTest(test.TestCase):
|
||||
mock_policy_update_check_call, mock_policy_show_check_call])
|
||||
quota_sets.db.share_type_get_by_name_or_id.assert_not_called()
|
||||
|
||||
@ddt.data(_get_request(True, True), _get_request(True, False))
|
||||
def test_update_quota_with_value_greater_than_2147483647(self, req):
|
||||
value = 2147483648
|
||||
body = {'quota_set': {'tenant_id': self.project_id, 'shares': value}}
|
||||
|
||||
if req == _get_request(True, True):
|
||||
self.mock_policy_update_check_call = mock.call(
|
||||
req.environ['manila.context'], self.resource_name, 'update')
|
||||
self.assertRaises(
|
||||
webob.exc.HTTPBadRequest,
|
||||
self.controller.update,
|
||||
req, self.project_id, body
|
||||
)
|
||||
self.mock_policy_check.assert_called_once_with(
|
||||
req.environ['manila.context'], self.resource_name, 'update')
|
||||
|
||||
if req == _get_request(True, False):
|
||||
self.assertRaises(
|
||||
webob.exc.HTTPBadRequest,
|
||||
self.controller.update,
|
||||
req, self.project_id, body
|
||||
)
|
||||
self.mock_policy_check.assert_not_called()
|
||||
|
||||
@ddt.data('2.39', '2.40')
|
||||
def test_update_share_type_quota(self, microversion):
|
||||
self.mock_object(
|
||||
|
Loading…
x
Reference in New Issue
Block a user