Merge "Big Switch: Catch exceptions in watchdog thread"

This commit is contained in:
Jenkins 2014-06-16 04:58:10 +00:00 committed by Gerrit Code Review
commit c6bc0040f7
2 changed files with 13 additions and 4 deletions

View File

@ -556,7 +556,11 @@ class ServerPool(object):
# doesn't match, the backend will return a synchronization error
# that will be handled by the rest_action.
eventlet.sleep(polling_interval)
self.rest_action('GET', HEALTH_PATH)
try:
self.rest_action('GET', HEALTH_PATH)
except Exception:
LOG.exception(_("Encountered an error checking controller "
"health."))
class HTTPSConnectionWithValidation(httplib.HTTPSConnection):

View File

@ -83,17 +83,22 @@ class ServerManagerTests(test_rp.BigSwitchProxyPluginV2TestCase):
mock.patch(
SERVERMANAGER + '.ServerPool.rest_call',
side_effect=servermanager.RemoteRestError(
reason='Failure to break loop'
reason='Failure to trigger except clause.'
)
),
mock.patch(
SERVERMANAGER + '.LOG.exception',
side_effect=KeyError('Failure to break loop')
)
) as (smock, rmock):
) as (smock, rmock, lmock):
# should return immediately without consistency capability
pl.servers._consistency_watchdog()
self.assertFalse(smock.called)
pl.servers.capabilities = ['consistency']
self.assertRaises(servermanager.RemoteRestError,
self.assertRaises(KeyError,
pl.servers._consistency_watchdog)
rmock.assert_called_with('GET', '/health', '', {}, [], False)
self.assertEqual(1, len(lmock.mock_calls))
def test_consistency_hash_header(self):
# mock HTTP class instead of rest_call so we can see headers