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>
This commit is contained in:
Chuan Miao 2019-06-20 18:29:54 +02:00 committed by Maurice Escher
parent cc729152ec
commit 5c858bc528
No known key found for this signature in database
GPG Key ID: 8AD448124C3F2F77
3 changed files with 11 additions and 5 deletions

View File

@ -1171,10 +1171,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

@ -1399,7 +1399,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.