Fix detaching a volume that failed to attach

Change-Id: I240e0816bd03653636fa19164d9ffe35d03e1fa3
Closes-Bug: #1849535
This commit is contained in:
Hongbin Lu 2019-10-24 03:31:48 +00:00
parent 6c7cbe2559
commit 499a547007
2 changed files with 5 additions and 3 deletions

View File

@ -119,7 +119,8 @@ class CinderVolumeDriverTestCase(base.TestCase):
mock_get_mountpoint.assert_called_once_with(self.fake_uuid)
mock_do_mount.assert_called_once_with(
self.fake_devpath, self.fake_mountpoint, CONF.volume.fstype)
mock_cinder_workflow.detach_volume.assert_called_once_with(self.volmap)
mock_cinder_workflow.detach_volume.assert_called_once_with(
self.context, self.volmap)
@mock.patch('zun.common.mount.do_mount')
@mock.patch('oslo_utils.fileutils.ensure_tree')
@ -150,7 +151,8 @@ class CinderVolumeDriverTestCase(base.TestCase):
mock_get_mountpoint.assert_called_once_with(self.fake_uuid)
mock_do_mount.assert_called_once_with(
self.fake_devpath, self.fake_mountpoint, CONF.volume.fstype)
mock_cinder_workflow.detach_volume.assert_called_once_with(self.volmap)
mock_cinder_workflow.detach_volume.assert_called_once_with(
self.context, self.volmap)
@mock.patch('shutil.rmtree')
@mock.patch('zun.common.mount.do_unmount')

View File

@ -140,7 +140,7 @@ class Cinder(VolumeDriver):
with excutils.save_and_reraise_exception():
LOG.exception("Failed to mount device")
try:
cinder.detach_volume(volmap)
cinder.detach_volume(context, volmap)
except Exception:
LOG.exception("Failed to detach volume")