Don't leave snapshots on the floor
The current cloning process in the LVM
driver uses a snapshot to do the data
copy in the background. Trouble here
is that if the creation or activation
of the new volume fails, we don't
cleanup the snapshot we created.
Just move the create_volume and activate
calls down into the try block so the finally
clause can do the cleanup for us.
Change-Id: If0fbab9d9f39102cdc7d287527be22c4a2b35934
Closes-Bug: #1312718
(cherry picked from commit 38ed052312
)
This commit is contained in:
parent
2e628c1598
commit
63ba651c12
@ -291,16 +291,17 @@ class LVMVolumeDriver(driver.VolumeDriver):
|
||||
'id': temp_id}
|
||||
|
||||
self.create_snapshot(temp_snapshot)
|
||||
self._create_volume(volume['name'],
|
||||
self._sizestr(volume['size']),
|
||||
self.configuration.lvm_type,
|
||||
mirror_count)
|
||||
|
||||
self.vg.activate_lv(temp_snapshot['name'], is_snapshot=True)
|
||||
|
||||
# copy_volume expects sizes in MiB, we store integer GiB
|
||||
# be sure to convert before passing in
|
||||
try:
|
||||
self._create_volume(volume['name'],
|
||||
self._sizestr(volume['size']),
|
||||
self.configuration.lvm_type,
|
||||
mirror_count)
|
||||
|
||||
self.vg.activate_lv(temp_snapshot['name'], is_snapshot=True)
|
||||
|
||||
volutils.copy_volume(
|
||||
self.local_path(temp_snapshot),
|
||||
self.local_path(volume),
|
||||
|
Loading…
Reference in New Issue
Block a user