Handle inst not found exceptions in pollsters

Updates the CPU/Net/Disk compute pollsters so we handle
instance not found exceptions. These types of exceptions may
occur when an instance has been deleted during sample processing.

Fixes LP Bug #1223098.

Change-Id: Icc8a79f8c23276b68aa27e758872ff80ad484061
This commit is contained in:
Dan Prince 2013-09-09 21:15:52 -04:00
parent 46b51362da
commit 7aeefa0e99
3 changed files with 12 additions and 0 deletions

View File

@ -21,6 +21,7 @@
from ceilometer import sample
from ceilometer.compute import plugin
from ceilometer.compute.pollsters import util
from ceilometer.compute.virt import inspector as virt_inspector
from ceilometer.openstack.common import log
LOG = log.getLogger(__name__)
@ -44,6 +45,9 @@ class CPUPollster(plugin.ComputePollster):
volume=cpu_info.time,
additional_metadata=cpu_num,
)
except virt_inspector.InstanceNotFoundException as err:
# Instance was deleted while getting samples. Ignore it.
LOG.debug('Exception while getting samples %s', err)
except Exception as err:
LOG.error('could not get CPU time for %s: %s',
instance.id, err)

View File

@ -24,6 +24,7 @@ import collections
from ceilometer import sample
from ceilometer.compute import plugin
from ceilometer.compute.pollsters import util
from ceilometer.compute.virt import inspector as virt_inspector
from ceilometer.openstack.common import log
LOG = log.getLogger(__name__)
@ -86,6 +87,9 @@ class _Base(plugin.ComputePollster):
instance_name,
)
yield self._get_sample(instance, c_data)
except virt_inspector.InstanceNotFoundException as err:
# Instance was deleted while getting samples. Ignore it.
LOG.debug('Exception while getting samples %s', err)
except Exception as err:
LOG.warning('Ignoring instance %s: %s',
instance_name, err)

View File

@ -23,6 +23,7 @@ import copy
from ceilometer import sample
from ceilometer.compute import plugin
from ceilometer.compute.pollsters import util
from ceilometer.compute.virt import inspector as virt_inspector
from ceilometer.openstack.common import log
from ceilometer.openstack.common import timeutils
@ -83,6 +84,9 @@ class _Base(plugin.ComputePollster):
LOG.info(self.NET_USAGE_MESSAGE, instance_name,
vnic.name, info.rx_bytes, info.tx_bytes)
yield self._get_sample(instance, vnic, info)
except virt_inspector.InstanceNotFoundException as err:
# Instance was deleted while getting samples. Ignore it.
LOG.debug('Exception while getting samples %s', err)
except Exception as err:
LOG.warning('Ignoring instance %s: %s',
instance_name, err)