Fix over-quota exception of snapshot creation

Report consumed snapshot gigabytes instead of share gigabytes

Change-Id: I917d3c68fc2014d4bdeefbf7c473ebc2bf6d8979
Closes-Bug: #1859775
Co-authored-by: Maurice Escher <maurice.escher@sap.com>
(cherry picked from commit 5c858bc528)
(cherry picked from commit 9c07eb3151)
This commit is contained in:
Chuan Miao 2019-06-20 18:29:54 +02:00 committed by Goutham Pacha Ravi
parent 0dc9e9105e
commit 5f91ab3520
3 changed files with 11 additions and 5 deletions

View File

@ -1106,10 +1106,11 @@ class API(base.Base):
msg = ("Quota exceeded for %(s_pid)s, tried to create "
"%(s_size)sG snapshot (%(d_consumed)dG of "
"%(d_quota)dG already consumed).")
LOG.warning(msg, {'s_pid': context.project_id,
's_size': size,
'd_consumed': _consumed('gigabytes'),
'd_quota': quotas['snapshot_gigabytes']})
LOG.warning(msg, {
's_pid': context.project_id,
's_size': size,
'd_consumed': _consumed('snapshot_gigabytes'),
'd_quota': quotas['snapshot_gigabytes']})
raise exception.SnapshotSizeExceedsAvailableQuota()
elif 'snapshots' in overs:
msg = ("Quota exceeded for %(s_pid)s, tried to create "

View File

@ -1251,7 +1251,7 @@ class ShareAPITestCase(test.TestCase):
share = fakes.fake_share(
id=uuidutils.generate_uuid(), size=1, project_id='fake_project',
user_id='fake_user', has_replicas=False, status='available')
usages = {'gigabytes': {'reserved': 10, 'in_use': 0}}
usages = {'snapshot_gigabytes': {'reserved': 10, 'in_use': 0}}
quotas = {'snapshot_gigabytes': 10}
side_effect = exception.OverQuota(
overs='snapshot_gigabytes', usages=usages, quotas=quotas)

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Fixed Quota exceeded exception for snapshot creation. Consumed gigabytes
now reports the snapshot gigabytes instead of share gigabytes usage.