Merge "Fix issues with failed lvremove"

This commit is contained in:
Jenkins
2013-09-23 07:28:01 +00:00
committed by Gerrit Code Review
3 changed files with 28 additions and 4 deletions

View File

@@ -408,10 +408,26 @@ class LVM(executor.Executor):
:param name: Name of LV to delete
"""
self._execute('lvremove',
'-f',
'%s/%s' % (self.vg_name, name),
root_helper=self._root_helper, run_as_root=True)
try:
self._execute('lvremove',
'-f',
'%s/%s' % (self.vg_name, name),
root_helper=self._root_helper, run_as_root=True)
except putils.ProcessExecutionError as err:
mesg = (_('Error reported running lvremove: CMD: %(command)s, '
'RESPONSE: %(response)s') %
{'command': err.cmd, 'response': err.stderr})
LOG.error(mesg)
LOG.warning(_('Attempting udev settle and retry of lvremove...'))
self._execute('udevadm', 'settle',
root_helper=self._root_helper,
run_as_root=True)
self._execute('lvremove',
'-f',
'%s/%s' % (self.vg_name, name),
root_helper=self._root_helper, run_as_root=True)
def revert(self, snapshot_name):
"""Revert an LV from snapshot.

View File

@@ -179,11 +179,18 @@ class LVMVolumeDriver(driver.VolumeDriver):
def delete_volume(self, volume):
"""Deletes a logical volume."""
# NOTE(jdg): We don't need to explicitly call
# remove export here because we already did it
# in the manager before we got here.
if self._volume_not_present(volume['name']):
# If the volume isn't present, then don't attempt to delete
return True
if self.vg.lv_has_snapshot(volume['name']):
LOG.error(_('Unabled to delete due to existing snapshot '
'for volume: %s') % volume['name'])
raise exception.VolumeIsBusy(volume_name=volume['name'])
self._delete_volume(volume)

View File

@@ -46,6 +46,7 @@ dmsetup: CommandFilter, dmsetup, root
ln: CommandFilter, ln, root
qemu-img: CommandFilter, qemu-img, root
env: CommandFilter, env, root
udevadm: CommandFilter, udevadm, root
# cinder/volume/driver.py: utils.read_file_as_root()
cat: CommandFilter, cat, root