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

fix(console,computes): an unreachable host is named as the cause, not an empty list

The console page of a VM whose host does not answer said "Fail to get
console. Please check the console configuration of your VM." and logged
nothing. It now shows the connection error (to users who do not see the
hosts, that the host cannot be reached) and logs it with the VM and host.

A host's Storage, Networks, Interfaces, Filters and Secrets pages showed
the connection error and also "This host has no ...". The list is None
when it was not read, and the page shows only the error.
This commit is contained in:
catborise 2026-11-06 23:08:11 +03:00
parent 39dda65132
commit d1fb9bd2d4
14 changed files with 72 additions and 18 deletions

View file

@ -2,6 +2,7 @@
import functools
import json
import logging
from pathlib import Path
from appsettings.settings import app_settings
@ -12,9 +13,13 @@ from django.utils.translation import gettext_lazy as _
from instances.models import Instance
from instances.utils import can_open_console
from libvirt import libvirtError
from operations.utils import safe_text
from vrtManager.connection import CONN_TCP, CONN_TLS
from vrtManager.instance import wvmInstance
from vrtManager.util import is_loopback
from webvirtcloud.middleware import error_text
logger = logging.getLogger(__name__)
# one file a layout, written by dev/console_layout.py
LAYOUTS_DIR = Path(__file__).resolve().parent / "layouts"
@ -60,7 +65,11 @@ def console(request, compute_id, uuid):
unreachable = instance.compute.type in (CONN_TCP, CONN_TLS) and bool(
conn.get_console_socket() or is_loopback(conn.get_console_listener_addr())
)
except (libvirtError, ValueError, IndexError):
except libvirtError as err:
# the host or the VM could not be read: the page says that, not to check the console settings
logger.warning("Console of %s on %s: %s", instance.name, instance.compute.name, safe_text(err))
return render(request, "console-error.html", {"instance": instance, "console_error": error_text(request, err)})
except (ValueError, IndexError):
running = unreachable = False
console_type = None
console_passwd = None