From 1f0ae02f1e42acc0304b34179d0527d8e2e6533a Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 15 May 2012 15:27:13 -0400 Subject: [PATCH] Add an exception handler to deal with errors that occur when the info in nova is out of sync with reality (as on my currently broken system). Also adds a nova prefix to the logger for now so messages from this module make it into the log file. Change-Id: I57dc7e74a16955bcf42e9360e7de6e2f26ca09b0 --- ceilometer/nova/manager.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/ceilometer/nova/manager.py b/ceilometer/nova/manager.py index 6a847138..f70860dc 100644 --- a/ceilometer/nova/manager.py +++ b/ceilometer/nova/manager.py @@ -29,7 +29,10 @@ import nova.notifier.rabbit_notifier from ceilometer import rpc FLAGS = flags.FLAGS -LOG = logging.getLogger(__name__) +# FIXME(dhellmann): We need to have the main program set up logging +# correctly so messages from modules outside of the nova package +# appear in the output. +LOG = logging.getLogger('nova.' + __name__) class InstanceManager(manager.Manager): @@ -51,8 +54,9 @@ class ComputeManager(manager.Manager): domain = conn._conn.lookupByName(instance) tree = etree.fromstring(domain.XMLDesc(0)) return filter(bool, - [target.get('dev') \ - for target in tree.findall('devices/disk/target')]) + [target.get('dev') + for target in tree.findall('devices/disk/target') + ]) @manager.periodic_task def _fetch_diskio(self, context): @@ -62,6 +66,12 @@ class ComputeManager(manager.Manager): self.host): # TODO(jd) This does not work see bug#998089 # for disk in conn.get_disks(instance.name): - for disk in self._get_disks(conn, instance.name): + try: + disks = self._get_disks(conn, instance.name) + except Exception as err: + LOG.warning('Ignoring instance %s: %s', instance.name, err) + LOG.exception(err) + continue + for disk in disks: stats = conn.block_stats(instance.name, disk) LOG.info("DISKIO USAGE: %s %s: read-requests=%d read-bytes=%d write-requests=%d write-bytes=%d errors=%d" % (instance, disk, stats[0], stats[1], stats[2], stats[3], stats[4]))