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

fix(instances): a busy host is reported as busy, not as unreachable

A web request refused because this process's requests to the host
(HOST_REQUESTS) all still wait for it raised the same ConnectionFailed as
a host that is down, so the VM page said the host cannot be reached. It
now raises HostBusy; the VM page and the error users who do not see hosts
get say the host is busy and to try again in a moment.
This commit is contained in:
catborise 2026-11-05 15:53:29 +03:00
parent 93790f0178
commit e40ab1485c
9 changed files with 307 additions and 245 deletions

View file

@ -19,7 +19,7 @@ from libvirt import libvirtError
from accounts.models import UserInstance
from appsettings.models import AppSettings
from instances.models import Instance
from vrtManager.util import ConnectionFailed, OperationError, render
from vrtManager.util import ConnectionFailed, HostBusy, OperationError, render
from . import jobs
@ -50,6 +50,7 @@ TRANSPORT_ERROR_CODES = {
libvirt.VIR_ERR_LIBSSH,
}
UNREACHABLE = gettext_noop("The host of this virtual machine cannot be reached right now.")
HOST_BUSY = gettext_noop("The host of this virtual machine is busy with other requests right now: try again in a moment.")
BOUNDS = {"WORKER_CONCURRENCY": (1, 16, 4), "JOB_RETENTION_DAYS": (1, 3650, 30), "LOG_RETENTION_DAYS": (1, 3650, 365)}
@ -102,6 +103,8 @@ def public_error(exception):
and exception.get_error_domain() in TRANSPORT_ERROR_DOMAINS
and exception.get_error_code() in TRANSPORT_ERROR_CODES
)
if isinstance(exception, HostBusy):
return say(HOST_BUSY)
return say(UNREACHABLE) if connection_error else said(exception)