Log health manager exceptions

The executor will hide any unhandled exceptions raised from the update_health
or update_stats methods. This patch updates the health manager to log those
exceptions.

Change-Id: I941730c5e0964ec319b5eb2b7992335b71f9d134
This commit is contained in:
Michael Johnson 2018-03-14 17:27:22 -07:00
parent 03e5ae0799
commit 24cd007075
2 changed files with 17 additions and 1 deletions

View File

@ -75,6 +75,14 @@ class UpdateHealthDb(update_base.HealthUpdateBase):
self.emit(entity_type, entity_id, message)
def update_health(self, health):
# The executor will eat any exceptions from the update_health code
# so we need to wrap it and log the unhandled exception
try:
self._update_health(health)
except Exception:
LOG.exception('update_health encountered an unknown error')
def _update_health(self, health):
"""This function is to update db info based on amphora status
:param health: map object that contains amphora, listener, member info
@ -319,6 +327,14 @@ class UpdateStatsDb(update_base.StatsUpdateBase, stats.StatsMixin):
self.event_streamer.emit(cnt)
def update_stats(self, health_message):
# The executor will eat any exceptions from the update_stats code
# so we need to wrap it and log the unhandled exception
try:
self._update_stats(health_message)
except Exception:
LOG.exception('update_stats encountered an unknown error')
def _update_stats(self, health_message):
"""This function is to update the db with listener stats
:param health_message: The health message containing the listener stats

View File

@ -183,7 +183,7 @@ class TestUpdateHealthDb(base.TestCase):
self.amphora_repo.get_all_lbs_on_amphora.return_value = []
self.assertRaises(TestException, self.hm.update_health, health)
self.hm.update_health(health)
self.assertTrue(self.amphora_health_repo.replace.called)
self.session_mock.rollback.assert_called_once()