summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhangtralon <zhangchunlong1@huawei.com>2014-07-03 11:45:40 +0800
committerzhangtralon <zhangchunlong1@huawei.com>2014-09-02 00:29:07 +0000
commitd7d4ef350c971c442954d772b639f8b673630896 (patch)
tree0c1a187a17528ec777d226180c99b262a2c8d60a
parent3ab81c9b3eb87093b902c25e4edfc9eaf986356c (diff)
downloadnova-d7d4ef350c971c442954d772b639f8b673630896.tar.gz
the headroom infomation is incomplete
If multiple resources beyond the quotas in 'limit_check' from nova/quota.py. The headroom information about the resources beyond the quotas in OverQuota Exception is incomplete. Change-Id: I790c22e3618a3558dfad64bf46e37e4e49f6385e Closes-Bug: #1334965
-rw-r--r--nova/quota.py15
-rw-r--r--nova/tests/test_quota.py9
2 files changed, 14 insertions, 10 deletions
diff --git a/nova/quota.py b/nova/quota.py
index b98282ecb1..20225b3b5a 100644
--- a/nova/quota.py
+++ b/nova/quota.py
@@ -452,16 +452,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)
diff --git a/nova/tests/test_quota.py b/nova/tests/test_quota.py
index b00ed7e9e1..763c85d39b 100644
--- a/nova/tests/test_quota.py
+++ b/nova/tests/test_quota.py
@@ -1947,6 +1947,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()