From 87baa22317cdc6cb42a5ea4739c7fd0f2f56d503 Mon Sep 17 00:00:00 2001 From: Tobias Urdin Date: Mon, 9 Jun 2025 13:47:09 +0200 Subject: [PATCH] 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 70a56ba670157bf72d1513b8c177c9294071e2eb) Signed-off-by: Tobias Urdin --- ceilometer/compute/virt/libvirt/inspector.py | 8 +++++++- releasenotes/notes/bug-2113768-a2db3a59c8e13558.yaml | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/bug-2113768-a2db3a59c8e13558.yaml diff --git a/ceilometer/compute/virt/libvirt/inspector.py b/ceilometer/compute/virt/libvirt/inspector.py index f5001e35c5..32baac3e20 100644 --- a/ceilometer/compute/virt/libvirt/inspector.py +++ b/ceilometer/compute/virt/libvirt/inspector.py @@ -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) diff --git a/releasenotes/notes/bug-2113768-a2db3a59c8e13558.yaml b/releasenotes/notes/bug-2113768-a2db3a59c8e13558.yaml new file mode 100644 index 0000000000..6aaa447b8c --- /dev/null +++ b/releasenotes/notes/bug-2113768-a2db3a59c8e13558.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Fixed `bug #2113768 `__ where + the Libvirt inspector did not catch exceptions thrown when calling interfaceStats + function on a domain.