1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-02 00:46:05 +00:00

fix(instances): the VM list survives a host that stops answering mid-request

The VM list reads each reachable host's CPUs and memory while it renders,
after it has found the host reachable. When the network to a host
dropped during that request, libvirt's keepalive closed the connection
in between, and the read raised: the whole list became the 500 error
page after about 40 s. Only the next load showed the host as down.

The host's CPU, memory and memory-use reads now give None for a host
that stopped answering; the list leaves its numbers out and the New VM
dialog does not offer it. Checked on compute1 with its libvirt port
dropped mid-request: the list answers 200.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
This commit is contained in:
catborise 2026-11-10 10:56:25 +03:00
parent b70bab2144
commit 6cdda6d4f3
4 changed files with 35 additions and 5 deletions

View file

@ -88,17 +88,28 @@ class Compute(Model):
self.type,
)
# The VM list reads these when it renders, after status: a host that
# stopped answering meanwhile gives None, not an error page.
@cached_property
def cpu_count(self):
return self.proxy.host_info[2]
try:
return self.proxy.host_info[2]
except libvirtError:
return None
@cached_property
def ram_size(self):
return self.proxy.host_info[1] * 1048576 # MiB
try:
return self.proxy.host_info[1] * 1048576 # MiB
except libvirtError:
return None
@cached_property
def ram_usage(self):
return self.proxy.get_memory_usage()["percent"]
try:
return self.proxy.get_memory_usage()["percent"]
except libvirtError:
return None
@cached_property
def capacity(self):