Don't obscure logs on iSCSI sendtargets failure
On iSCSI connections that make use of discovery we will be obscuring the the logs if the sendtargets command fails because when we try to do the cleanup another exception will be raised (TargetPortalsNotFound). The original exception is still logged since we are using excutils.save_and_reraise_exception(), but it will be misleading if we don't pay close attention. This patch fixes this by ignoring the 'Unable to find target portals information on discoverydb.' error, but logging a debug log message, when doing the cleanup because this exception means that the sendtargets failed and therefore we don't have anything to cleanup. Change-Id: I7ddf827c7f2285acd72fd5a2fcd351928cb5d2df
This commit is contained in:
parent
66520dcf6c
commit
8e4adda001
|
@ -857,8 +857,14 @@ class ISCSIConnector(base.BaseLinuxConnector, base_iscsi.BaseISCSIConnector):
|
|||
:type ignore_errors: bool
|
||||
"""
|
||||
exc = exception.ExceptionChainer()
|
||||
devices_map = self._get_connection_devices(connection_properties,
|
||||
ips_iqns_luns)
|
||||
try:
|
||||
devices_map = self._get_connection_devices(connection_properties,
|
||||
ips_iqns_luns)
|
||||
except exception.TargetPortalsNotFound as exc:
|
||||
# When discovery sendtargets failed on connect there is no
|
||||
# information in the discoverydb, so there's nothing to clean.
|
||||
LOG.debug('Skipping cleanup %s', exc)
|
||||
return
|
||||
|
||||
# Remove devices and multipath from this connection
|
||||
remove_devices = set()
|
||||
|
|
|
@ -709,6 +709,16 @@ class ISCSIConnectorTestCase(test_connector.ConnectorTestCase):
|
|||
mock.sentinel.force, mock.ANY)
|
||||
flush_mock.assert_called_once_with(mock.sentinel.mp_name)
|
||||
|
||||
def test_cleanup_connection_no_data_discoverydb(self):
|
||||
self.connector.use_multipath = True
|
||||
with mock.patch.object(self.connector, '_get_discoverydb_portals',
|
||||
side_effect=exception.TargetPortalsNotFound), \
|
||||
mock.patch.object(self.connector._linuxscsi,
|
||||
'remove_connection') as mock_remove:
|
||||
# This will not raise and exception
|
||||
self.connector._cleanup_connection(self.SINGLE_CON_PROPS)
|
||||
mock_remove.assert_not_called()
|
||||
|
||||
@ddt.data({'do_raise': False, 'force': False},
|
||||
{'do_raise': True, 'force': True},
|
||||
{'do_raise': True, 'force': False})
|
||||
|
|
Loading…
Reference in New Issue