From d1cc60a21559e6065b41b1ecbd73df12bab77b6a Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Thu, 25 Feb 2016 18:21:54 -0500 Subject: [PATCH] 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 --- nova/servicegroup/drivers/db.py | 8 +++++--- nova/tests/unit/cells/test_cells_state_manager.py | 3 ++- nova/tests/unit/servicegroup/test_db_servicegroup.py | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/nova/servicegroup/drivers/db.py b/nova/servicegroup/drivers/db.py index 99bad8522ed0..fa440700a1bb 100644 --- a/nova/servicegroup/drivers/db.py +++ b/nova/servicegroup/drivers/db.py @@ -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): diff --git a/nova/tests/unit/cells/test_cells_state_manager.py b/nova/tests/unit/cells/test_cells_state_manager.py index 7f72a3d9f4ff..62e55779ef83 100644 --- a/nova/tests/unit/cells/test_cells_state_manager.py +++ b/nova/tests/unit/cells/test_cells_state_manager.py @@ -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] diff --git a/nova/tests/unit/servicegroup/test_db_servicegroup.py b/nova/tests/unit/servicegroup/test_db_servicegroup.py index aa6472115b0c..d7f857a37b29 100644 --- a/nova/tests/unit/servicegroup/test_db_servicegroup.py +++ b/nova/tests/unit/servicegroup/test_db_servicegroup.py @@ -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,