iSCSI single path: Don't fail if there's no WWN

This patch relaxes the single-pathed connections and allows them to
complete even when we cannot detect the WWN on the sysfs, just like
multipath connections do.

Closes-Bug: #1834443
Change-Id: Iae5a304329a2b172bc6b7f310623fad18956ae45
This commit is contained in:
Gorka Eguileor 2019-06-27 11:19:15 +02:00
parent 4ec35ed3b0
commit 1c07f221f2
2 changed files with 26 additions and 3 deletions

View File

@ -571,10 +571,12 @@ class ISCSIConnector(base.BaseLinuxConnector, base_iscsi.BaseISCSIConnector):
for __ in range(10):
wwn = self._linuxscsi.get_sysfs_wwn(found_devs)
if wwn:
return self._get_connect_result(connection_properties,
wwn, found_devs)
break
time.sleep(1)
LOG.debug('Could not find the WWN for %s.', found_devs[0])
else:
LOG.debug('Could not find the WWN for %s.', found_devs[0])
return self._get_connect_result(connection_properties,
wwn, found_devs)
# If we failed we must cleanup the connection, as we could be
# leaving the node entry if it's not being used by another device.

View File

@ -1111,6 +1111,27 @@ Setting up iSCSI targets: unused
(('ip1:port1', 'tgt1', 4),),
force=True, ignore_errors=True)
@mock.patch.object(linuxscsi.LinuxSCSI, 'get_sysfs_wwn', return_value='')
@mock.patch.object(iscsi.ISCSIConnector, '_connect_vol')
@mock.patch.object(iscsi.ISCSIConnector, '_cleanup_connection')
@mock.patch('time.sleep')
def test_connect_single_volume_no_wwn(self, sleep_mock, cleanup_mock,
connect_mock, get_wwn_mock):
def my_connect(rescans, props, data):
data['found_devices'].append('sdz')
connect_mock.side_effect = my_connect
res = self.connector._connect_single_volume(self.CON_PROPS)
expected = {'type': 'block', 'scsi_wwn': '', 'path': '/dev/sdz'}
self.assertEqual(expected, res)
get_wwn_mock.assert_has_calls([mock.call(['sdz'])] * 10)
self.assertEqual(10, get_wwn_mock.call_count)
sleep_mock.assert_has_calls([mock.call(1)] * 10)
self.assertEqual(10, sleep_mock.call_count)
cleanup_mock.assert_not_called()
@staticmethod
def _get_connect_vol_data():
return {'stop_connecting': False, 'num_logins': 0, 'failed_logins': 0,