Revert consumed quota when failed to create group from source group

When failed to created corresponding volumes in group, Cinder
will destory the volume object, but consumed quota is left.

Change-Id: Ief0637768cf1fe04bb4162e02008b4884a184051
This commit is contained in:
TommyLike
2018-01-31 08:58:30 +08:00
parent cf56cdd4da
commit 91c672e340
2 changed files with 141 additions and 2 deletions

View File

@@ -318,7 +318,9 @@ class API(base.Base):
volumes = objects.VolumeList.get_all_by_generic_group(
context, group.id)
for vol in volumes:
vol.destroy()
# NOTE(tommylikehu): `delete` is used here in order to
# revert consumed quota.
self.volume_api.delete(context, vol)
group.destroy()
finally:
LOG.error("Error occurred when creating group "
@@ -399,7 +401,9 @@ class API(base.Base):
volumes = objects.VolumeList.get_all_by_generic_group(
context, group.id)
for vol in volumes:
vol.destroy()
# NOTE(tommylikehu): `delete` is used here in order to
# revert consumed quota.
self.volume_api.delete(context, vol)
group.destroy()
finally:
LOG.error("Error occurred when creating "