host manager: Log the host generating the warning

Currently we are logging a warning when there's a discrepancy between
the host's available disk stored in the database and the disk reported
by the compute node, but there's no information about which host
generates that error.

Change-Id: I8d6704fa76f2750e0e986b8399f9fe358b3fad93
This commit is contained in:
Alvaro Lopez Garcia 2014-10-23 18:16:42 +02:00
parent 54b0da2974
commit c680b0d9d3
2 changed files with 9 additions and 6 deletions

View File

@ -182,9 +182,11 @@ class HostState(object):
if least_gb is not None:
if least_gb > free_gb:
# can occur when an instance in database is not on host
LOG.warn(_LW("Host has more disk space than database "
"expected (%(physical)sgb > %(database)sgb)"),
{'physical': least_gb, 'database': free_gb})
LOG.warn(_LW("Host %(hostname)s has more disk space than "
"database expected "
"(%(physical)sgb > %(database)sgb)"),
{'physical': least_gb, 'database': free_gb,
'hostname': compute['hypervisor_hostname']})
free_gb = min(least_gb, free_gb)
free_disk_mb = free_gb * 1024

View File

@ -282,10 +282,11 @@ class HostManagerTestCase(test.NoDBTestCase):
db.compute_node_get_all(context).AndReturn(fakes.COMPUTE_NODES)
# node 3 host physical disk space is greater than database
host_manager.LOG.warn(_LW("Host has more disk space than database "
"expected (%(physical)sgb > "
host_manager.LOG.warn(_LW("Host %(hostname)s has more disk space than "
"database expected (%(physical)sgb > "
"%(database)sgb)"),
{'physical': 3333, 'database': 3072})
{'physical': 3333, 'database': 3072,
'hostname': 'node3'})
# Invalid service
host_manager.LOG.warn(_LW("No service for compute ID %s"), 5)