Ensure device node exists before wiping during volume deletion

If the LVM device node is missing when a Cinder volume is deleted,
a large amount of data will be written to /dev/.  Check that the
device node exists before performing a _copy_volume('/dev/zero'...)
to wipe it.  Fixes bug 1070023.

Change-Id: I77a0a5545a54a4adc905a781ed8120db7adccc27
This commit is contained in:
Eric Harney 2012-10-22 18:02:17 -04:00
parent 186e32da97
commit 8b58a4605f

View File

@ -147,9 +147,9 @@ class VolumeDriver(object):
"""Deletes a logical volume."""
# zero out old volumes to prevent data leaking between users
# TODO(ja): reclaiming space should be done lazy and low priority
self._copy_volume('/dev/zero', self.local_path(volume), size_in_g)
dev_path = self.local_path(volume)
if os.path.exists(dev_path):
self._copy_volume('/dev/zero', dev_path, size_in_g)
self._try_execute('dmsetup', 'remove', '-f', dev_path,
run_as_root=True)
self._try_execute('lvremove', '-f', "%s/%s" %