linuxscsi: Only raise and log multipathd errors when required
Logging and then ignoring multipathd errors when it isn't enforced is confusing to operators investigating attach or detach issues. Change-Id: Ib234e585da5644d87fcf1ef6bcb95f2871dc6b32
This commit is contained in:
parent
736454730f
commit
bdfe6b43cb
|
@ -218,13 +218,13 @@ class LinuxSCSI(executor.Executor):
|
||||||
# code and just printed the error message in stdout.
|
# code and just printed the error message in stdout.
|
||||||
if out and out.startswith('error receiving packet'):
|
if out and out.startswith('error receiving packet'):
|
||||||
raise putils.ProcessExecutionError('', out, 1, cmd, None)
|
raise putils.ProcessExecutionError('', out, 1, cmd, None)
|
||||||
|
|
||||||
except putils.ProcessExecutionError as err:
|
except putils.ProcessExecutionError as err:
|
||||||
LOG.error('multipathd is not running: exit code %(err)s',
|
|
||||||
{'err': err.exit_code})
|
|
||||||
if enforce_multipath:
|
if enforce_multipath:
|
||||||
|
LOG.error('multipathd is not running: exit code %(err)s',
|
||||||
|
{'err': err.exit_code})
|
||||||
raise
|
raise
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def get_dm_name(self, dm):
|
def get_dm_name(self, dm):
|
||||||
|
|
|
@ -912,20 +912,59 @@ loop0 0"""
|
||||||
self.assertEqual(expected, result)
|
self.assertEqual(expected, result)
|
||||||
|
|
||||||
@mock.patch('os_brick.privileged.rootwrap.execute', return_value=('', ''))
|
@mock.patch('os_brick.privileged.rootwrap.execute', return_value=('', ''))
|
||||||
def test_is_multipath_running_default_executor(self, mock_exec):
|
def test_is_multipath_running(self, mock_exec):
|
||||||
res = linuxscsi.LinuxSCSI.is_multipath_running(False, None, mock_exec)
|
res = linuxscsi.LinuxSCSI.is_multipath_running(False, None, mock_exec)
|
||||||
self.assertTrue(res)
|
self.assertTrue(res)
|
||||||
mock_exec.assert_called_once_with(
|
mock_exec.assert_called_once_with(
|
||||||
'multipathd', 'show', 'status', run_as_root=True, root_helper=None)
|
'multipathd', 'show', 'status', run_as_root=True, root_helper=None)
|
||||||
|
|
||||||
|
@mock.patch.object(linuxscsi, 'LOG')
|
||||||
@mock.patch('os_brick.privileged.rootwrap.execute')
|
@mock.patch('os_brick.privileged.rootwrap.execute')
|
||||||
def test_is_multipath_running_failure_exit_code_0(self, mock_exec):
|
def test_is_multipath_running_failure(
|
||||||
|
self, mock_exec, mock_log
|
||||||
|
):
|
||||||
|
mock_exec.side_effect = putils.ProcessExecutionError()
|
||||||
|
self.assertRaises(putils.ProcessExecutionError,
|
||||||
|
linuxscsi.LinuxSCSI.is_multipath_running,
|
||||||
|
True, None, mock_exec)
|
||||||
|
mock_log.error.assert_called_once()
|
||||||
|
|
||||||
|
@mock.patch.object(linuxscsi, 'LOG')
|
||||||
|
@mock.patch('os_brick.privileged.rootwrap.execute')
|
||||||
|
def test_is_multipath_running_failure_exit_code_0(
|
||||||
|
self, mock_exec, mock_log
|
||||||
|
):
|
||||||
mock_exec.return_value = ('error receiving packet', '')
|
mock_exec.return_value = ('error receiving packet', '')
|
||||||
self.assertRaises(putils.ProcessExecutionError,
|
self.assertRaises(putils.ProcessExecutionError,
|
||||||
linuxscsi.LinuxSCSI.is_multipath_running,
|
linuxscsi.LinuxSCSI.is_multipath_running,
|
||||||
True, None, mock_exec)
|
True, None, mock_exec)
|
||||||
mock_exec.assert_called_once_with(
|
mock_exec.assert_called_once_with(
|
||||||
'multipathd', 'show', 'status', run_as_root=True, root_helper=None)
|
'multipathd', 'show', 'status', run_as_root=True, root_helper=None)
|
||||||
|
mock_log.error.assert_called_once()
|
||||||
|
|
||||||
|
@mock.patch.object(linuxscsi, 'LOG')
|
||||||
|
@mock.patch('os_brick.privileged.rootwrap.execute')
|
||||||
|
def test_is_multipath_running_failure_not_enforcing_multipath(
|
||||||
|
self, mock_exec, mock_log
|
||||||
|
):
|
||||||
|
mock_exec.side_effect = putils.ProcessExecutionError()
|
||||||
|
res = linuxscsi.LinuxSCSI.is_multipath_running(False, None, mock_exec)
|
||||||
|
mock_exec.assert_called_once_with(
|
||||||
|
'multipathd', 'show', 'status', run_as_root=True, root_helper=None)
|
||||||
|
self.assertFalse(res)
|
||||||
|
mock_log.error.assert_not_called()
|
||||||
|
|
||||||
|
@mock.patch.object(linuxscsi, 'LOG')
|
||||||
|
@mock.patch('os_brick.privileged.rootwrap.execute')
|
||||||
|
def test_is_multipath_running_failure_not_enforcing_exit_code_0(
|
||||||
|
self, mock_exec, mock_log
|
||||||
|
):
|
||||||
|
mock_exec.return_value = ('error receiving packet', '')
|
||||||
|
res = linuxscsi.LinuxSCSI.is_multipath_running(False, None, mock_exec)
|
||||||
|
mock_exec.assert_called_once_with(
|
||||||
|
'multipathd', 'show', 'status', run_as_root=True, root_helper=None)
|
||||||
|
self.assertFalse(res)
|
||||||
|
mock_log.error.assert_not_called()
|
||||||
|
|
||||||
def test_get_device_info(self):
|
def test_get_device_info(self):
|
||||||
ret = "[1:1:0:0] disk Vendor Array 0100 /dev/adevice\n"
|
ret = "[1:1:0:0] disk Vendor Array 0100 /dev/adevice\n"
|
||||||
|
|
Loading…
Reference in New Issue