From 5871380e1bb265b4d4c20342873db2b8b5d28b6a Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Wed, 10 Jun 2020 17:10:46 -0400 Subject: [PATCH] Avoid crashing VM stats thread if domain migrated --- node-daemon/pvcnoded/Daemon.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/node-daemon/pvcnoded/Daemon.py b/node-daemon/pvcnoded/Daemon.py index 6fe9a2e4..357d1215 100644 --- a/node-daemon/pvcnoded/Daemon.py +++ b/node-daemon/pvcnoded/Daemon.py @@ -1326,22 +1326,27 @@ def collect_vm_stats(queue): # Get statistics from any running VMs for domain in running_domains: - # Get basic information about the VM - tree = ElementTree.fromstring(domain.XMLDesc()) - domain_uuid = domain.UUIDString() - domain_name = domain.name() + try: + # Get basic information about the VM + tree = ElementTree.fromstring(domain.XMLDesc()) + domain_uuid = domain.UUIDString() + domain_name = domain.name() + + # Get all the raw information about the VM + if debug: + print("Getting general statistics for VM {}".format(domain_name)) + domain_state, domain_maxmem, domain_mem, domain_vcpus, domain_cputime = domain.info() + domain_memory_stats = domain.memoryStats() + domain_cpu_stats = domain.getCPUStats(True)[0] + except Exception as e: + if debug: + print("Failed getting VM information for {}: {}".format(domain_name, e)) + continue # Ensure VM is present in the domain_list if domain_uuid not in this_node.domain_list: this_node.domain_list.append(domain_uuid) - # Get all the raw information about the VM - if debug: - print("Getting general statistics for VM {}".format(domain_name)) - domain_state, domain_maxmem, domain_mem, domain_vcpus, domain_cputime = domain.info() - domain_memory_stats = domain.memoryStats() - domain_cpu_stats = domain.getCPUStats(True)[0] - if debug: print("Getting disk statistics for VM {}".format(domain_name)) domain_disk_stats = []