Catch exceptions for interfaceStats in libvirt inspector

In the Libvirt inspector we call the interfaceStats()
function but there is a race between us checking if
the domain is stopped and calling interfaceStats.

This adds a try-catch around interfaceStats the
same way as is already done for blockStats etc.

Closes-Bug: #2113768
Change-Id: I25ba64f5eefe8140b45bc4ff7e20c323dc5efd79
(cherry picked from commit 70a56ba670)
Signed-off-by: Tobias Urdin <tobias.urdin@binero.com>
This commit is contained in:
Tobias Urdin
2025-06-09 13:47:09 +02:00
parent 8dc61a6f58
commit 87baa22317
2 changed files with 13 additions and 1 deletions

View File

@@ -114,7 +114,13 @@ class LibvirtInspector(virt_inspector.Inspector):
params['interfaceid'] = interfaceid
params['bridge'] = bridge
dom_stats = domain.interfaceStats(name)
try:
dom_stats = domain.interfaceStats(name)
except libvirt.libvirtError as ex:
LOG.warning(_("Error from libvirt when running instanceStats, "
"This may not be harmful, but please check : "
"%(ex)s") % {'ex': ex})
continue
# Retrieve previous values
prev = self.cache.get(name)

View File

@@ -0,0 +1,6 @@
---
fixes:
- |
Fixed `bug #2113768 <https://bugs.launchpad.net/ceilometer/+bug/2113768>`__ where
the Libvirt inspector did not catch exceptions thrown when calling interfaceStats
function on a domain.