From 5f1432ccdd38996dac0f528035634cbc82827abd Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Fri, 10 Nov 2023 10:29:32 -0500 Subject: [PATCH] Fix memory allocation updates and add more debug Previously, we were assigning memalloc/memprov/vcpualloc during an earlier phase using the main d_domain list. I'm not sure exactly why, but this was throwing off stats after a fence. Instead, set these values later on while parsing the actually-active VMs. --- node-daemon/pvcnoded/util/keepalive.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/node-daemon/pvcnoded/util/keepalive.py b/node-daemon/pvcnoded/util/keepalive.py index 7ee3d0a9..96da259f 100644 --- a/node-daemon/pvcnoded/util/keepalive.py +++ b/node-daemon/pvcnoded/util/keepalive.py @@ -477,10 +477,6 @@ def collect_vm_stats(logger, config, zkhandler, this_node, queue): fixed_d_domain = this_node.d_domain.copy() for domain, instance in fixed_d_domain.items(): if domain in this_node.domain_list: - # Add the allocated memory to our memalloc value - memalloc += instance.getmemory() - memprov += instance.getmemory() - vcpualloc += instance.getvcpus() if instance.getstate() == "start" and instance.getnode() == this_node.name: if instance.getdom() is not None: try: @@ -536,6 +532,11 @@ def collect_vm_stats(logger, config, zkhandler, this_node, queue): continue domain_memory_stats = domain.memoryStats() domain_cpu_stats = domain.getCPUStats(True)[0] + + # Add the allocated memory to our memalloc value + memalloc += instance.getmemory() + memprov += instance.getmemory() + vcpualloc += instance.getvcpus() except Exception as e: if debug: try: @@ -667,6 +668,13 @@ def collect_vm_stats(logger, config, zkhandler, this_node, queue): # Close the Libvirt connection lv_conn.close() + if debug: + logger.out( + f"VM stats: doms: {len(running_domains)}; memalloc: {memalloc}; memprov: {memprov}; vcpualloc: {vcpualloc}", + state="d", + prefix="vm-thread", + ) + queue.put(len(running_domains)) queue.put(memalloc) queue.put(memprov)