Make unified limits APIs return reserved of 0
Currently the noop driver returns a reserved value of -1, and before this patch the same is true with the unified limits driver. Given the way the quota system currently works, the reserved value can be ignored. With unified limits, we want to make the API look as identical as possible to the DB driver, when you have the same limits applied with the unified limits driver. As such, we change the API to return a reserved value of 0 for the unified limits driver. Longer term, when the API gets a new microversion to tidy up quotas, the reserved value will likely be removed in the new microversion, because it no longer has any real meaning. blueprint unified-limits-nova Change-Id: I28212857313ae72903d2139884750d5de690c6bd
This commit is contained in:
committed by
melanie witt
parent
6acefc6b10
commit
a0c2bd4176
+13
-3
@@ -53,6 +53,10 @@ class DbQuotaDriver(object):
|
||||
"""
|
||||
UNLIMITED_VALUE = -1
|
||||
|
||||
def get_reserved(self):
|
||||
# Since we stopped reserving the DB, we just return 0
|
||||
return 0
|
||||
|
||||
def get_defaults(self, context, resources):
|
||||
"""Given a list of resources, retrieve the default quotas.
|
||||
Use the class quotas named `_DEFAULT_QUOTA_NAME` as default quotas,
|
||||
@@ -615,6 +619,10 @@ class NoopQuotaDriver(object):
|
||||
wish to have any quota checking.
|
||||
"""
|
||||
|
||||
def get_reserved(self):
|
||||
# Noop has always returned -1 for reserved
|
||||
return -1
|
||||
|
||||
def get_defaults(self, context, resources):
|
||||
"""Given a list of resources, retrieve the default quotas.
|
||||
|
||||
@@ -780,6 +788,10 @@ class UnifiedLimitsDriver(NoopQuotaDriver):
|
||||
LOG.warning("The Unified Limits Quota Driver is experimental and "
|
||||
"is under active development. Do not use this driver.")
|
||||
|
||||
def get_reserved(self):
|
||||
# To make unified limits APIs the same as the DB driver, return 0
|
||||
return 0
|
||||
|
||||
|
||||
class BaseResource(object):
|
||||
"""Describe a single resource for quota checking."""
|
||||
@@ -1067,9 +1079,7 @@ class QuotaEngine(object):
|
||||
return sorted(self._resources.keys())
|
||||
|
||||
def get_reserved(self):
|
||||
if isinstance(self._driver, NoopQuotaDriver):
|
||||
return -1
|
||||
return 0
|
||||
return self._driver.get_reserved()
|
||||
|
||||
|
||||
@api_db_api.context_manager.reader
|
||||
|
||||
@@ -666,6 +666,7 @@ class QuotaSetsTestV275(QuotaSetsTestV257):
|
||||
|
||||
class NoopQuotaSetsTest(test.NoDBTestCase):
|
||||
quota_driver = "nova.quota.NoopQuotaDriver"
|
||||
expected_detail = {'in_use': -1, 'limit': -1, 'reserved': -1}
|
||||
|
||||
def setUp(self):
|
||||
super(NoopQuotaSetsTest, self).setUp()
|
||||
@@ -716,24 +717,24 @@ class NoopQuotaSetsTest(test.NoDBTestCase):
|
||||
def test_detail_v21(self):
|
||||
req = fakes.HTTPRequest.blank("")
|
||||
response = self.controller.detail(req, uuids.project_id)
|
||||
expected_detail = {'in_use': -1, 'limit': -1, 'reserved': -1}
|
||||
|
||||
expected_response = {
|
||||
'quota_set': {
|
||||
'id': uuids.project_id,
|
||||
'cores': expected_detail,
|
||||
'fixed_ips': expected_detail,
|
||||
'floating_ips': expected_detail,
|
||||
'injected_file_content_bytes': expected_detail,
|
||||
'injected_file_path_bytes': expected_detail,
|
||||
'injected_files': expected_detail,
|
||||
'instances': expected_detail,
|
||||
'key_pairs': expected_detail,
|
||||
'metadata_items': expected_detail,
|
||||
'ram': expected_detail,
|
||||
'security_group_rules': expected_detail,
|
||||
'security_groups': expected_detail,
|
||||
'server_group_members': expected_detail,
|
||||
'server_groups': expected_detail,
|
||||
'cores': self.expected_detail,
|
||||
'fixed_ips': self.expected_detail,
|
||||
'floating_ips': self.expected_detail,
|
||||
'injected_file_content_bytes': self.expected_detail,
|
||||
'injected_file_path_bytes': self.expected_detail,
|
||||
'injected_files': self.expected_detail,
|
||||
'instances': self.expected_detail,
|
||||
'key_pairs': self.expected_detail,
|
||||
'metadata_items': self.expected_detail,
|
||||
'ram': self.expected_detail,
|
||||
'security_group_rules': self.expected_detail,
|
||||
'security_groups': self.expected_detail,
|
||||
'server_group_members': self.expected_detail,
|
||||
'server_groups': self.expected_detail,
|
||||
}
|
||||
}
|
||||
self.assertEqual(expected_response, response)
|
||||
@@ -741,24 +742,23 @@ class NoopQuotaSetsTest(test.NoDBTestCase):
|
||||
def test_detail_v21_user(self):
|
||||
req = fakes.HTTPRequest.blank("?user_id=42")
|
||||
response = self.controller.detail(req, uuids.project_id)
|
||||
expected_detail = {'in_use': -1, 'limit': -1, 'reserved': -1}
|
||||
expected_response = {
|
||||
'quota_set': {
|
||||
'id': uuids.project_id,
|
||||
'cores': expected_detail,
|
||||
'fixed_ips': expected_detail,
|
||||
'floating_ips': expected_detail,
|
||||
'injected_file_content_bytes': expected_detail,
|
||||
'injected_file_path_bytes': expected_detail,
|
||||
'injected_files': expected_detail,
|
||||
'instances': expected_detail,
|
||||
'key_pairs': expected_detail,
|
||||
'metadata_items': expected_detail,
|
||||
'ram': expected_detail,
|
||||
'security_group_rules': expected_detail,
|
||||
'security_groups': expected_detail,
|
||||
'server_group_members': expected_detail,
|
||||
'server_groups': expected_detail,
|
||||
'cores': self.expected_detail,
|
||||
'fixed_ips': self.expected_detail,
|
||||
'floating_ips': self.expected_detail,
|
||||
'injected_file_content_bytes': self.expected_detail,
|
||||
'injected_file_path_bytes': self.expected_detail,
|
||||
'injected_files': self.expected_detail,
|
||||
'instances': self.expected_detail,
|
||||
'key_pairs': self.expected_detail,
|
||||
'metadata_items': self.expected_detail,
|
||||
'ram': self.expected_detail,
|
||||
'security_group_rules': self.expected_detail,
|
||||
'security_groups': self.expected_detail,
|
||||
'server_group_members': self.expected_detail,
|
||||
'server_groups': self.expected_detail,
|
||||
}
|
||||
}
|
||||
self.assertEqual(expected_response, response)
|
||||
@@ -867,3 +867,4 @@ class NoopQuotaSetsTest(test.NoDBTestCase):
|
||||
|
||||
class UnifiedLimitsQuotaSetsTest(NoopQuotaSetsTest):
|
||||
quota_driver = "nova.quota.UnifiedLimitsDriver"
|
||||
expected_detail = {'in_use': -1, 'limit': -1, 'reserved': 0}
|
||||
|
||||
Reference in New Issue
Block a user