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
This commit is contained in:
Lucian Petrut 2017-08-14 15:43:50 +03:00
parent 78686e448b
commit 20412248b7
2 changed files with 7 additions and 2 deletions

View File

@ -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,

View File

@ -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(