feat(servers): distinguish rejected credentials from unreachable nodes

An offline server used to report a single "Failed to connect" state, but
"the node does not answer" and "the node answered 401" are fixed in
completely different ways — the first is power or network, the second is a
stale token, which is what happens when a node joins a cluster and its
user.cfg and priv/token.cfg are replaced by the cluster ones.

- add ProxmoxClient.check_connection() returning (ok, error_kind, error);
  token auth surfaces 401 as ResourceException rather than
  AuthenticationError, since proxmoxer validates the token on first use
- store the reason in proxmox_servers.last_error_kind (migration 40) and
  expose it through the server response
- surface an auth_error state in the UI with a hint explaining the usual
  cause

Storage listings now also report per-node availability: the cluster config
declares a storage for the whole cluster but says nothing about whether it
actually came up on a given node, so a missing volume group or pool stayed
invisible. Availability comes from a single /cluster/resources call.
This commit is contained in:
markmorado
2026-07-24 04:42:59 +05:00
parent db7411b1bf
commit 075b8cdaaa
15 changed files with 218 additions and 31 deletions

View File

@@ -152,6 +152,38 @@ class StorageMixin:
logger.error(f"Ошибка получения хранилищ ({content}) ноды {node}: {e}")
return result
def get_storage_node_status(self) -> Dict[str, List[Dict[str, Any]]]:
"""
Доступность каждого хранилища по нодам — одним запросом /cluster/resources.
Конфиг кластера (/storage) не знает, поднялось ли хранилище на конкретной
ноде: VG/пул может быть объявлен, но физически отсутствовать — типичный
случай после ввода новой ноды в кластер, где локальные хранилища ноды
заменяются кластерным конфигом.
Хранилища, отключённые в конфиге (disable), в /cluster/resources не
попадают, поэтому в карте их не будет.
Returns:
{storage_id: [{'node': 'prod', 'active': True}, ...]}
"""
if not self.proxmox:
return {}
status: Dict[str, List[Dict[str, Any]]] = {}
try:
for res in self.get_cluster_resources(type_='storage'):
storage_id = res.get('storage')
node = res.get('node')
if not storage_id or not node:
continue
status.setdefault(storage_id, []).append({
'node': node,
'active': res.get('status') == 'available',
})
except Exception as e:
logger.error(f"Ошибка получения статусов хранилищ с {self.host}: {e}")
return status
def get_node_storages(self, node: str, content: str = None) -> List[Dict]:
"""Get storages available on a specific node, optionally filtered by content type"""
if not self.proxmox: