Remove skip_validation_flag to False by default
Remove the skip_validation to force quota validation. Closes-bug: #1735337 Change-Id: Ib9596ac3ecc57a4f825b7d7118014e2ac14b2473
This commit is contained in:
parent
7ffc39f071
commit
7310676502
@ -2350,13 +2350,6 @@ size:
|
|||||||
in: body
|
in: body
|
||||||
required: true
|
required: true
|
||||||
type: integer
|
type: integer
|
||||||
skip_validation:
|
|
||||||
description: |
|
|
||||||
If set to false, the quota value can't be set lower than the in_use quota.
|
|
||||||
Default is True.
|
|
||||||
in: body
|
|
||||||
required: false
|
|
||||||
type: boolean
|
|
||||||
snapshot:
|
snapshot:
|
||||||
description: |
|
description: |
|
||||||
A partial representation of a snapshot used in
|
A partial representation of a snapshot used in
|
||||||
|
@ -130,7 +130,6 @@ Request
|
|||||||
- gigabytes: gigabytes
|
- gigabytes: gigabytes
|
||||||
- gigabytes_{volume_type}: gigabytes_for_type
|
- gigabytes_{volume_type}: gigabytes_for_type
|
||||||
- backup_gigabytes: backup_gigabytes
|
- backup_gigabytes: backup_gigabytes
|
||||||
- skip_validation: skip_validation
|
|
||||||
|
|
||||||
Request Example
|
Request Example
|
||||||
---------------
|
---------------
|
||||||
|
@ -5,5 +5,4 @@
|
|||||||
"volumes_ceph": 3,
|
"volumes_ceph": 3,
|
||||||
"backups": 4
|
"backups": 4
|
||||||
},
|
},
|
||||||
"skip_validation": false
|
|
||||||
}
|
}
|
||||||
|
@ -211,21 +211,6 @@ class QuotaSetsController(wsgi.Controller):
|
|||||||
|
|
||||||
self.assert_valid_body(body, 'quota_set')
|
self.assert_valid_body(body, 'quota_set')
|
||||||
|
|
||||||
# TODO(wxy): Change "skip_validation"'s default value to False in
|
|
||||||
# Queens.
|
|
||||||
# Get the optional argument 'skip_validation' from body,
|
|
||||||
# if skip_validation is False, then validate existing resource.
|
|
||||||
skip_flag = body.get('skip_validation', True)
|
|
||||||
if not strutils.is_valid_boolstr(skip_flag):
|
|
||||||
msg = _("Invalid value '%s' for skip_validation.") % skip_flag
|
|
||||||
raise exception.InvalidParameterValue(err=msg)
|
|
||||||
skip_flag = strutils.bool_from_string(skip_flag)
|
|
||||||
if skip_flag:
|
|
||||||
LOG.warning("It's unsafe to skip validating the existing "
|
|
||||||
"resource's quota when updating it. Cinder will force "
|
|
||||||
"validate it in Queens, please try to use "
|
|
||||||
"skip_validation=False for quota updating now.")
|
|
||||||
|
|
||||||
bad_keys = []
|
bad_keys = []
|
||||||
|
|
||||||
# NOTE(ankit): Pass #1 - In this loop for body['quota_set'].items(),
|
# NOTE(ankit): Pass #1 - In this loop for body['quota_set'].items(),
|
||||||
@ -280,10 +265,7 @@ class QuotaSetsController(wsgi.Controller):
|
|||||||
body['quota_set'][key], key, min_value=-1,
|
body['quota_set'][key], key, min_value=-1,
|
||||||
max_value=db.MAX_INT)
|
max_value=db.MAX_INT)
|
||||||
|
|
||||||
# Can't skip the validation of nested quotas since it could mess up
|
self._validate_existing_resource(key, value, quota_values)
|
||||||
# hierarchy if parent limit is less than childrens' current usage
|
|
||||||
if not skip_flag or use_nested_quotas:
|
|
||||||
self._validate_existing_resource(key, value, quota_values)
|
|
||||||
|
|
||||||
if use_nested_quotas:
|
if use_nested_quotas:
|
||||||
try:
|
try:
|
||||||
|
@ -309,33 +309,16 @@ class QuotaSetsControllerTest(QuotaSetsControllerTestBase):
|
|||||||
db.quota_usage_get_all_by_project(ctxt,
|
db.quota_usage_get_all_by_project(ctxt,
|
||||||
fake.PROJECT_ID))
|
fake.PROJECT_ID))
|
||||||
|
|
||||||
def test_update_lower_than_existing_resources_when_skip_false(self):
|
def test_update_lower_than_existing_resources(self):
|
||||||
self._commit_quota_reservation()
|
self._commit_quota_reservation()
|
||||||
body = {'quota_set': {'volumes': 0},
|
body = {'quota_set': {'volumes': 0}}
|
||||||
'skip_validation': 'false'}
|
|
||||||
self.assertRaises(webob.exc.HTTPBadRequest, self.controller.update,
|
self.assertRaises(webob.exc.HTTPBadRequest, self.controller.update,
|
||||||
self.req, fake.PROJECT_ID, body)
|
self.req, fake.PROJECT_ID, body)
|
||||||
# Ensure that validation works even if some resources are valid
|
# Ensure that validation works even if some resources are valid
|
||||||
body = {'quota_set': {'gigabytes': 1, 'volumes': 10},
|
body = {'quota_set': {'gigabytes': 1, 'volumes': 10}}
|
||||||
'skip_validation': 'false'}
|
|
||||||
self.assertRaises(webob.exc.HTTPBadRequest, self.controller.update,
|
self.assertRaises(webob.exc.HTTPBadRequest, self.controller.update,
|
||||||
self.req, fake.PROJECT_ID, body)
|
self.req, fake.PROJECT_ID, body)
|
||||||
|
|
||||||
def test_update_lower_than_existing_resources_when_skip_true(self):
|
|
||||||
self._commit_quota_reservation()
|
|
||||||
body = {'quota_set': {'volumes': 0},
|
|
||||||
'skip_validation': 'true'}
|
|
||||||
result = self.controller.update(self.req, fake.PROJECT_ID, body)
|
|
||||||
self.assertEqual(body['quota_set']['volumes'],
|
|
||||||
result['quota_set']['volumes'])
|
|
||||||
|
|
||||||
def test_update_lower_than_existing_resources_without_skip_argument(self):
|
|
||||||
self._commit_quota_reservation()
|
|
||||||
body = {'quota_set': {'volumes': 0}}
|
|
||||||
result = self.controller.update(self.req, fake.PROJECT_ID, body)
|
|
||||||
self.assertEqual(body['quota_set']['volumes'],
|
|
||||||
result['quota_set']['volumes'])
|
|
||||||
|
|
||||||
def test_delete(self):
|
def test_delete(self):
|
||||||
result_show = self.controller.show(self.req, fake.PROJECT_ID)
|
result_show = self.controller.show(self.req, fake.PROJECT_ID)
|
||||||
self.assertDictEqual(make_body(), result_show)
|
self.assertDictEqual(make_body(), result_show)
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- Quota validations are now forced for all APIs. skip_validation flag is
|
||||||
|
now removed from the request body for the quota-set update API.
|
Loading…
Reference in New Issue
Block a user