Merge "the headroom infomation is incomplete"

This commit is contained in:
Jenkins 2014-09-21 13:44:02 +00:00 committed by Gerrit Code Review
commit 71a06db5cf
2 changed files with 14 additions and 10 deletions

View File

@ -458,16 +458,11 @@ class DbQuotaDriver(object):
(user_quotas[key] >= 0 and user_quotas[key] < val)]
if overs:
headroom = {}
# Check project_quotas:
for key in quotas:
if quotas[key] >= 0 and quotas[key] < val:
headroom[key] = quotas[key]
# Check user quotas:
for key in user_quotas:
if (user_quotas[key] >= 0 and user_quotas[key] < val and
headroom.get(key) > user_quotas[key]):
headroom[key] = user_quotas[key]
for key in overs:
headroom[key] = min(
val for val in (quotas.get(key), project_quotas.get(key))
if val is not None
)
raise exception.OverQuota(overs=sorted(overs), quotas=quotas,
usages={}, headroom=headroom)

View File

@ -2053,6 +2053,15 @@ class DbQuotaDriverTestCase(test.TestCase):
quota.QUOTAS._resources,
dict(metadata_items=129))
def test_limit_check_project_overs(self):
self._stub_get_project_quotas()
self.assertRaises(exception.OverQuota,
self.driver.limit_check,
FakeContext('test_project', 'test_class'),
quota.QUOTAS._resources,
dict(injected_file_content_bytes=10241,
injected_file_path_bytes=256))
def test_limit_check_unlimited(self):
self.flags(quota_metadata_items=-1)
self._stub_get_project_quotas()