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:
@@ -103,6 +103,9 @@ class ProxmoxServer(Base):
|
||||
|
||||
is_online = Column(Boolean, nullable=True, default=None)
|
||||
last_error = Column(Text, nullable=True)
|
||||
# Почему сервер недоступен: 'auth' — API ответил 401 (протух токен/пароль),
|
||||
# 'connection' — не отвечает вовсе. Лечится по-разному, поэтому различаем.
|
||||
last_error_kind = Column(String(20), nullable=True)
|
||||
|
||||
__table_args__ = (
|
||||
Index('idx_proxmox_status', 'is_online', 'last_check'),
|
||||
@@ -125,13 +128,15 @@ class ProxmoxServer(Base):
|
||||
'last_check': self.last_check
|
||||
}
|
||||
|
||||
def update_status(self, is_online: bool, error: str = None):
|
||||
def update_status(self, is_online: bool, error: str = None, error_kind: str = None):
|
||||
self.is_online = is_online
|
||||
self.last_check = utcnow()
|
||||
if error:
|
||||
self.last_error = error
|
||||
self.last_error_kind = error_kind or 'connection'
|
||||
elif is_online:
|
||||
self.last_error = None
|
||||
self.last_error_kind = None
|
||||
|
||||
assigned_users = relationship("User", secondary="user_servers", back_populates="assigned_servers", lazy="select")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user