Merge "Fix hostmonitor hanging forever after certain exceptions"
This commit is contained in:
commit
6e84289a53
|
@ -424,10 +424,9 @@ class HandleHost(driver.DriverBase):
|
|||
|
||||
This method monitors hosts.
|
||||
"""
|
||||
try:
|
||||
self.running = True
|
||||
while self.running:
|
||||
|
||||
self.running = True
|
||||
while self.running:
|
||||
try:
|
||||
# Check whether corosync communication between hosts
|
||||
# is normal.
|
||||
ret = self._check_hb_line()
|
||||
|
@ -466,9 +465,7 @@ class HandleHost(driver.DriverBase):
|
|||
if status_func() != 0:
|
||||
LOG.warning("hostmonitor skips monitoring hosts.")
|
||||
|
||||
eventlet.greenthread.sleep(CONF.host.monitoring_interval)
|
||||
except Exception as e:
|
||||
LOG.exception("Exception caught: %s", e)
|
||||
|
||||
except Exception as e:
|
||||
LOG.exception("Exception caught: %s", e)
|
||||
|
||||
return
|
||||
eventlet.greenthread.sleep(CONF.host.monitoring_interval)
|
||||
|
|
|
@ -859,25 +859,25 @@ class TestHandleHost(testtools.TestCase):
|
|||
def test_monitor_hosts(self,
|
||||
mock_check_hb_line,
|
||||
mock_check_pacemaker_services,
|
||||
mock_check_host_status_by_cibadmin,
|
||||
mock_check_host_status_by_crmadmin,
|
||||
mock_check_host_status_by_cibadmin,
|
||||
mock_sleep):
|
||||
|
||||
mock_check_hb_line.side_effect = \
|
||||
[0, 1, 2, 0, Exception("Test exception.")]
|
||||
mock_check_pacemaker_services.side_effect = [True, False, False]
|
||||
mock_check_host_status_by_cibadmin.side_effect = [0, 1]
|
||||
[0, 1, 2, 0, Exception("Test exception."), 0, KeyboardInterrupt()]
|
||||
mock_check_pacemaker_services.side_effect = [True, False, False, True]
|
||||
mock_check_host_status_by_crmadmin.side_effect = [0, 1]
|
||||
mock_check_host_status_by_cibadmin.side_effect = [0, 1, 0]
|
||||
mock_sleep.return_value = None
|
||||
|
||||
obj = handle_host.HandleHost()
|
||||
obj.monitor_hosts()
|
||||
self.assertRaises(KeyboardInterrupt, obj.monitor_hosts)
|
||||
|
||||
self.assertEqual(5, mock_check_hb_line.call_count)
|
||||
self.assertEqual(3, mock_check_pacemaker_services.call_count)
|
||||
self.assertEqual(7, mock_check_hb_line.call_count)
|
||||
self.assertEqual(4, mock_check_pacemaker_services.call_count)
|
||||
mock_check_pacemaker_services.assert_called_with('pacemaker_remote')
|
||||
self.assertEqual(2, mock_check_host_status_by_cibadmin.call_count)
|
||||
self.assertEqual(2, mock_check_host_status_by_crmadmin.call_count)
|
||||
self.assertEqual(3, mock_check_host_status_by_cibadmin.call_count)
|
||||
|
||||
@mock.patch.object(eventlet.greenthread, 'sleep')
|
||||
@mock.patch.object(handle_host.HandleHost,
|
||||
|
@ -892,16 +892,15 @@ class TestHandleHost(testtools.TestCase):
|
|||
|
||||
CONF.host.restrict_to_remotes = True
|
||||
mock_check_hb_line.side_effect = \
|
||||
[0, Exception("Test exception.")]
|
||||
[0, Exception("Test exception."), 0, KeyboardInterrupt()]
|
||||
mock_check_pacemaker_services.return_value = True
|
||||
mock_check_host_status_by_crm_mon.side_effect = 0
|
||||
mock_check_host_status_by_crm_mon.return_value = 0
|
||||
mock_sleep.return_value = None
|
||||
|
||||
obj = handle_host.HandleHost()
|
||||
obj.monitor_hosts()
|
||||
self.assertRaises(KeyboardInterrupt, obj.monitor_hosts)
|
||||
|
||||
self.assertEqual(1, mock_check_hb_line.call_count)
|
||||
self.assertEqual(1, mock_check_pacemaker_services.call_count)
|
||||
self.assertEqual(4, mock_check_hb_line.call_count)
|
||||
self.assertEqual(2, mock_check_pacemaker_services.call_count)
|
||||
mock_check_pacemaker_services.assert_called_with('pacemaker_remote')
|
||||
self.assertEqual(1, mock_check_host_status_by_crm_mon.call_count)
|
||||
mock_check_host_status_by_crm_mon.assert_called_once_with()
|
||||
self.assertEqual(2, mock_check_host_status_by_crm_mon.call_count)
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
fixes:
|
||||
- |
|
||||
Fixes hostmonitor hanging forever after certain exceptions.
|
||||
`LP#1930361 <https://launchpad.net/bugs/1930361>`__
|
Loading…
Reference in New Issue