Merge "Fix for volume detach error when use NFS as the cinder backend"
This commit is contained in:
commit
e86db61576
|
@ -718,6 +718,28 @@ class LibvirtVolumeTestCase(test.NoDBTestCase):
|
||||||
('umount', export_mnt_base)]
|
('umount', export_mnt_base)]
|
||||||
self.assertEqual(expected_commands, self.executes)
|
self.assertEqual(expected_commands, self.executes)
|
||||||
|
|
||||||
|
@mock.patch.object(volume.utils, 'execute')
|
||||||
|
@mock.patch.object(volume.LOG, 'debug')
|
||||||
|
@mock.patch.object(volume.LOG, 'exception')
|
||||||
|
def test_libvirt_nfs_driver_umount_error(self, mock_LOG_exception,
|
||||||
|
mock_LOG_debug, mock_utils_exe):
|
||||||
|
export_string = '192.168.1.1:/nfs/share1'
|
||||||
|
connection_info = {'data': {'export': export_string,
|
||||||
|
'name': self.name}}
|
||||||
|
libvirt_driver = volume.LibvirtNFSVolumeDriver(self.fake_conn)
|
||||||
|
mock_utils_exe.side_effect = processutils.ProcessExecutionError(
|
||||||
|
None, None, None, 'umount', 'umount: device is busy.')
|
||||||
|
libvirt_driver.disconnect_volume(connection_info, "vde")
|
||||||
|
self.assertTrue(mock_LOG_debug.called)
|
||||||
|
mock_utils_exe.side_effect = processutils.ProcessExecutionError(
|
||||||
|
None, None, None, 'umount', 'umount: target is busy.')
|
||||||
|
libvirt_driver.disconnect_volume(connection_info, "vde")
|
||||||
|
self.assertTrue(mock_LOG_debug.called)
|
||||||
|
mock_utils_exe.side_effect = processutils.ProcessExecutionError(
|
||||||
|
None, None, None, 'umount', 'umount: Other error.')
|
||||||
|
libvirt_driver.disconnect_volume(connection_info, "vde")
|
||||||
|
self.assertTrue(mock_LOG_exception.called)
|
||||||
|
|
||||||
def test_libvirt_nfs_driver_already_mounted(self):
|
def test_libvirt_nfs_driver_already_mounted(self):
|
||||||
# NOTE(vish) exists is to make driver assume connecting worked
|
# NOTE(vish) exists is to make driver assume connecting worked
|
||||||
mnt_base = '/mnt'
|
mnt_base = '/mnt'
|
||||||
|
|
|
@ -663,7 +663,8 @@ class LibvirtNFSVolumeDriver(LibvirtBaseVolumeDriver):
|
||||||
try:
|
try:
|
||||||
utils.execute('umount', mount_path, run_as_root=True)
|
utils.execute('umount', mount_path, run_as_root=True)
|
||||||
except processutils.ProcessExecutionError as exc:
|
except processutils.ProcessExecutionError as exc:
|
||||||
if 'target is busy' in exc.message:
|
if ('device is busy' in exc.message or
|
||||||
|
'target is busy' in exc.message):
|
||||||
LOG.debug("The NFS share %s is still in use.", export)
|
LOG.debug("The NFS share %s is still in use.", export)
|
||||||
else:
|
else:
|
||||||
LOG.exception(_LE("Couldn't unmount the NFS share %s"), export)
|
LOG.exception(_LE("Couldn't unmount the NFS share %s"), export)
|
||||||
|
|
Loading…
Reference in New Issue