fix crash when node has incoming VM migration

This commit is contained in:
illustris 2024-06-05 14:02:46 +05:30
parent 4416fbb6fe
commit 1eb1bf9053
Signed by: illustris
GPG Key ID: 56C8FC0B899FEFA3

View File

@ -147,11 +147,17 @@ def collect_kvm_metrics():
for proc in psutil.process_iter(['pid', 'name', 'exe', 'cmdline', 'cpu_percent', 'memory_percent', 'num_threads']): for proc in psutil.process_iter(['pid', 'name', 'exe', 'cmdline', 'cpu_percent', 'memory_percent', 'num_threads']):
try: try:
if proc.info['exe'] == '/usr/bin/qemu-system-x86_64': if proc.info['exe'] == '/usr/bin/qemu-system-x86_64':
vmid = flag_to_label_value(proc.info['cmdline'], "-id")
# Check if VM definition exists. If it is missing, qm commands will fail.
# VM configs are typically missing when a VM is migrating in.
# The config file is moved after the drives and memory are synced.
if not os.path.exists(f'/etc/pve/qemu-server/{vmid}.conf'):
continue
procs.append( procs.append(
( (
proc, proc,
proc.info['cmdline'], proc.info['cmdline'],
flag_to_label_value(proc.info['cmdline'], "-id") vmid
) )
) )
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess): except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):