From: John Griffith Date: Wed, 16 Jul 2014 14:49:37 +0000 (-0600) Subject: Don't leave snapshots on the floor X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=38ed0523125efeaf8383b36d1db169b42e2f5eb6;p=openstack-build%2Fcinder-build.git 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 --- diff --git a/cinder/volume/drivers/lvm.py b/cinder/volume/drivers/lvm.py index bdfe12d24..47ac5910f 100644 --- a/cinder/volume/drivers/lvm.py +++ b/cinder/volume/drivers/lvm.py @@ -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),