From 20412248b7c3910b5e87911d063049c4e0055688 Mon Sep 17 00:00:00 2001 From: Lucian Petrut Date: Mon, 14 Aug 2017 15:43:50 +0300 Subject: [PATCH] Fix SMB volume detachment issue A recent change introduced a regression which prevents SMB volumes from being detached. By passing the volume tag to os-win when detaching a disk, os-win then ignores the disk path and attempts to retrieve the attachment using the tag. Virtual images don't get tagged, for which reason detaches will fail siliently. For now, we'll just skip passing the tag when detaching such disks. Change-Id: Ie0500c29bfbbd63761b732872f1dda92720dbe21 Closes-Bug: #1710616 --- compute_hyperv/nova/volumeops.py | 5 ++++- compute_hyperv/tests/unit/test_volumeops.py | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/compute_hyperv/nova/volumeops.py b/compute_hyperv/nova/volumeops.py index 93b04145..8f9ff577 100644 --- a/compute_hyperv/nova/volumeops.py +++ b/compute_hyperv/nova/volumeops.py @@ -410,10 +410,13 @@ class BaseVolumeDriver(object): # on this tag. if not self._is_block_dev: disk_path = self.get_disk_resource_path(connection_info) + # In this case, we're not tagging the disks, so we want os-win + # to use the disk path to identify the attachment. + serial = None else: disk_path = None + serial = connection_info['serial'] - serial = connection_info['serial'] LOG.debug("Detaching disk from instance: %(instance_name)s. " "Disk path: %(disk_path)s. Disk serial tag: %(serial)s.", dict(disk_path=disk_path, diff --git a/compute_hyperv/tests/unit/test_volumeops.py b/compute_hyperv/tests/unit/test_volumeops.py index eea24857..4cb56a7f 100644 --- a/compute_hyperv/tests/unit/test_volumeops.py +++ b/compute_hyperv/tests/unit/test_volumeops.py @@ -624,9 +624,11 @@ class BaseVolumeDriverTestCase(test_base.HyperVBaseTestCase): mock.sentinel.instance_name) if is_block_dev: + exp_serial = connection_info['serial'] exp_disk_res_path = None self.assertFalse(mock_get_disk_resource_path.called) else: + exp_serial = None exp_disk_res_path = mock_get_disk_resource_path.return_value mock_get_disk_resource_path.assert_called_once_with( connection_info) @@ -635,7 +637,7 @@ class BaseVolumeDriverTestCase(test_base.HyperVBaseTestCase): mock.sentinel.instance_name, exp_disk_res_path, is_physical=is_block_dev, - serial=connection_info['serial']) + serial=exp_serial) def test_get_disk_ctrl_and_slot_ide(self): ctrl, slot = self._base_vol_driver._get_disk_ctrl_and_slot(