From 94b687502e57e256d942a6ebbebdc13b92a0cafd Mon Sep 17 00:00:00 2001 From: Hongbin Lu Date: Sat, 8 Sep 2018 20:19:29 +0000 Subject: [PATCH] Don't unmount device twice On deleting a container with auto-removed cinder volume, the method '_unmount_device' is called twice. The second call will fail because the device is already unmounted and the directory is deleted. This commit fixes this issue. Closes-Bug: #1791469 Change-Id: If94b0fb52e0dd6766941fc76a4690b5ec33c0a37 --- zun/tests/unit/volume/test_driver.py | 4 +--- zun/volume/driver.py | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/zun/tests/unit/volume/test_driver.py b/zun/tests/unit/volume/test_driver.py index e093f7f48..6e7aed2f9 100644 --- a/zun/tests/unit/volume/test_driver.py +++ b/zun/tests/unit/volume/test_driver.py @@ -185,12 +185,11 @@ class CinderVolumeDriverTestCase(base.TestCase): self.assertEqual(self.fake_container_path, destination) mock_get_mountpoint.assert_called_once_with(self.fake_uuid) - @mock.patch('shutil.rmtree') @mock.patch('zun.common.mount.get_mountpoint') @mock.patch('zun.common.mount.Mounter.read_mounts') @mock.patch('zun.volume.cinder_workflow.CinderWorkflow') def test_delete(self, mock_cinder_workflow_cls, mock_read_mounts, - mock_get_mountpoint, mock_rmtree): + mock_get_mountpoint): mock_cinder_workflow = mock.MagicMock() mock_cinder_workflow_cls.return_value = mock_cinder_workflow mock_cinder_workflow.delete_volume.return_value = self.fake_volume_id @@ -200,7 +199,6 @@ class CinderVolumeDriverTestCase(base.TestCase): volume_driver.delete(self.context, self.volume) mock_cinder_workflow.delete_volume.assert_called_once_with(self.volume) - mock_rmtree.assert_called_once_with(self.fake_mountpoint) class LocalVolumeDriverTestCase(base.TestCase): diff --git a/zun/volume/driver.py b/zun/volume/driver.py index 74086da69..cad0c11ee 100644 --- a/zun/volume/driver.py +++ b/zun/volume/driver.py @@ -159,7 +159,6 @@ class Cinder(VolumeDriver): @validate_volume_provider(supported_providers) def delete(self, context, volume): - self._unmount_device(volume) cinder = cinder_workflow.CinderWorkflow(context) cinder.delete_volume(volume)