Browse Source

Fix gigabytes usage error when deleting snapshot group

When deleting snapshot group,  the number of snapshots
is well decremented  with the number of snapshots present
in the group. But not the number of gigabytes.

Change-Id: I0fe6d4682a16cbe30e563079964a5275bac728bb
Closes-Bug: #1809434
changes/63/626863/7
Nolwenn Cauchois 3 years ago
parent
commit
e0048d4c99
  1. 17
      cinder/tests/unit/group/test_groups_manager.py
  2. 2
      cinder/volume/manager.py

17
cinder/tests/unit/group/test_groups_manager.py

@ -698,6 +698,11 @@ class GroupManagerTestCase(test.TestCase):
_mock_create_grp,
mock_notify):
"""Test group_snapshot can be created and deleted."""
original_add_volume_type_opts = quota.QUOTAS.add_volume_type_opts
quota.QUOTAS.add_volume_type_opts = mock.MagicMock(
side_effect=original_add_volume_type_opts
)
self.volume.cluster = cluster
group = tests_utils.create_group(
self.context,
@ -737,6 +742,18 @@ class GroupManagerTestCase(test.TestCase):
self.volume.delete_group_snapshot(self.context, group_snapshot)
reserve_opts = {
'snapshots': -1,
'gigabytes': 0
}
quota.QUOTAS.add_volume_type_opts.assert_called()
self.assertEqual(
(reserve_opts, fake.VOLUME_TYPE_ID),
quota.QUOTAS.add_volume_type_opts.call_args[0][1:]
)
quota.QUOTAS.add_volume_type_opts = original_add_volume_type_opts
self.assert_notify_called(mock_notify,
(['INFO', 'volume.create.start'],
['INFO', 'volume.create.end'],

2
cinder/volume/manager.py

@ -4019,6 +4019,8 @@ class VolumeManager(manager.CleanableManager,
# Get reservations
try:
reserve_opts = {'snapshots': -1}
if not CONF.no_snapshot_gb_quota:
reserve_opts['gigabytes'] = -snapshot.volume_size
volume_ref = objects.Volume.get_by_id(context,
snapshot.volume_id)
QUOTAS.add_volume_type_opts(context,

Loading…
Cancel
Save