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:
Chhavi Agarwal 2017-11-30 03:05:54 -05:00
parent 7ffc39f071
commit 7310676502
6 changed files with 8 additions and 48 deletions

View File

@ -2350,13 +2350,6 @@ size:
in: body
required: true
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:
description: |
A partial representation of a snapshot used in

View File

@ -130,7 +130,6 @@ Request
- gigabytes: gigabytes
- gigabytes_{volume_type}: gigabytes_for_type
- backup_gigabytes: backup_gigabytes
- skip_validation: skip_validation
Request Example
---------------

View File

@ -5,5 +5,4 @@
"volumes_ceph": 3,
"backups": 4
},
"skip_validation": false
}

View File

@ -211,21 +211,6 @@ class QuotaSetsController(wsgi.Controller):
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 = []
# 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,
max_value=db.MAX_INT)
# Can't skip the validation of nested quotas since it could mess up
# 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)
self._validate_existing_resource(key, value, quota_values)
if use_nested_quotas:
try:

View File

@ -309,33 +309,16 @@ class QuotaSetsControllerTest(QuotaSetsControllerTestBase):
db.quota_usage_get_all_by_project(ctxt,
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()
body = {'quota_set': {'volumes': 0},
'skip_validation': 'false'}
body = {'quota_set': {'volumes': 0}}
self.assertRaises(webob.exc.HTTPBadRequest, self.controller.update,
self.req, fake.PROJECT_ID, body)
# Ensure that validation works even if some resources are valid
body = {'quota_set': {'gigabytes': 1, 'volumes': 10},
'skip_validation': 'false'}
body = {'quota_set': {'gigabytes': 1, 'volumes': 10}}
self.assertRaises(webob.exc.HTTPBadRequest, self.controller.update,
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):
result_show = self.controller.show(self.req, fake.PROJECT_ID)
self.assertDictEqual(make_body(), result_show)

View File

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