diff --git a/api-ref/source/v3/parameters.yaml b/api-ref/source/v3/parameters.yaml index f0344ade3f0..7256e9cdf62 100644 --- a/api-ref/source/v3/parameters.yaml +++ b/api-ref/source/v3/parameters.yaml @@ -2370,13 +2370,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 diff --git a/api-ref/source/v3/quota-sets.inc b/api-ref/source/v3/quota-sets.inc index 38b0aee62ce..9e27556f6b8 100644 --- a/api-ref/source/v3/quota-sets.inc +++ b/api-ref/source/v3/quota-sets.inc @@ -130,7 +130,6 @@ Request - gigabytes: gigabytes - gigabytes_{volume_type}: gigabytes_for_type - backup_gigabytes: backup_gigabytes - - skip_validation: skip_validation Request Example --------------- diff --git a/api-ref/source/v3/samples/quotas-update-request.json b/api-ref/source/v3/samples/quotas-update-request.json index 7f0234ab86f..9735bb3cae2 100644 --- a/api-ref/source/v3/samples/quotas-update-request.json +++ b/api-ref/source/v3/samples/quotas-update-request.json @@ -5,5 +5,4 @@ "volumes_ceph": 3, "backups": 4 }, - "skip_validation": false } diff --git a/cinder/api/contrib/quotas.py b/cinder/api/contrib/quotas.py index ec4029e4ab5..f3268a97f58 100644 --- a/cinder/api/contrib/quotas.py +++ b/cinder/api/contrib/quotas.py @@ -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: diff --git a/cinder/tests/unit/api/contrib/test_quotas.py b/cinder/tests/unit/api/contrib/test_quotas.py index 2a0c5cb1639..8c9e279394b 100644 --- a/cinder/tests/unit/api/contrib/test_quotas.py +++ b/cinder/tests/unit/api/contrib/test_quotas.py @@ -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) diff --git a/releasenotes/notes/releasenotes/notes/bug-1735337-remove-skip-quota-validation-flag-2ecb24143f1f1292.yaml b/releasenotes/notes/releasenotes/notes/bug-1735337-remove-skip-quota-validation-flag-2ecb24143f1f1292.yaml new file mode 100644 index 00000000000..8d928c22ef7 --- /dev/null +++ b/releasenotes/notes/releasenotes/notes/bug-1735337-remove-skip-quota-validation-flag-2ecb24143f1f1292.yaml @@ -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.