Add service binary/host to service is down log for context

When we're logging that a service appears to be down in the
DB service group drive, add the service binary and host to
the message for context.

Change-Id: I8f676f7b498f4d7cb9b574a401ec892c2a3aacd3
Related-Bug: #1549854
This commit is contained in:
Matt Riedemann 2016-02-25 18:21:54 -05:00
parent 8974a30914
commit d1cc60a215
3 changed files with 8 additions and 4 deletions

View File

@ -75,9 +75,11 @@ class DbDriver(base.Driver):
elapsed = timeutils.delta_seconds(last_heartbeat, timeutils.utcnow())
is_up = abs(elapsed) <= self.service_down_time
if not is_up:
LOG.debug('Seems service is down. Last heartbeat was %(lhb)s. '
'Elapsed time is %(el)s',
{'lhb': str(last_heartbeat), 'el': str(elapsed)})
LOG.debug('Seems service %(binary)s on host %(host)s is down. '
'Last heartbeat was %(lhb)s. Elapsed time is %(el)s',
{'binary': service_ref.get('binary'),
'host': service_ref.get('host'),
'lhb': str(last_heartbeat), 'el': str(elapsed)})
return is_up
def _report_state(self, service):

View File

@ -92,7 +92,8 @@ def _fake_service_get_all_by_binary_nodedown(cls, context, binary):
return objects.Service(host=host,
disabled=False,
forced_down=False,
last_seen_up=last_seen)
last_seen_up=last_seen,
binary=binary)
return [_service(*fake) for fake in FAKE_SERVICES]

View File

@ -37,6 +37,7 @@ class DBServiceGroupTestCase(test.NoDBTestCase):
service = objects.Service(
host='fake-host',
topic='compute',
binary='nova-compute',
created_at=now,
updated_at=now,
last_seen_up=now,