fix: remote job stuck after SSH update completes (v0.5.4)
Treat agent_update_state as source of truth for active job; poll log thread no longer overwrites finished status.
This commit is contained in:
@@ -126,7 +126,10 @@ def _poll_ssh_update_log_loop(
|
||||
session = SessionLocal()
|
||||
try:
|
||||
row = session.get(Host, host_id)
|
||||
if row is None or row.agent_update_state != "running":
|
||||
if row is None or (row.agent_update_state or "").strip().lower() != "running":
|
||||
continue
|
||||
payload = dict(row.remote_action or {})
|
||||
if (payload.get("status") or "").strip().lower() != "running":
|
||||
continue
|
||||
cfg = get_effective_linux_admin_config(session)
|
||||
if not cfg.configured:
|
||||
@@ -148,7 +151,12 @@ def _poll_ssh_update_log_loop(
|
||||
continue
|
||||
if tail:
|
||||
break
|
||||
session.refresh(row)
|
||||
if (row.agent_update_state or "").strip().lower() != "running":
|
||||
continue
|
||||
payload = dict(row.remote_action or {})
|
||||
if (payload.get("status") or "").strip().lower() != "running":
|
||||
continue
|
||||
if tail:
|
||||
payload["output"] = tail
|
||||
payload["message"] = "Выполняется обновление… (лог с хоста)"
|
||||
@@ -339,8 +347,16 @@ def get_remote_action_status(host: Host) -> dict[str, Any]:
|
||||
payload = dict(host.remote_action or {})
|
||||
if not payload:
|
||||
return {"active": False, "host_id": host.id}
|
||||
status = payload.get("status") or host.agent_update_state or "unknown"
|
||||
active = status == "running" or host.agent_update_state == "running"
|
||||
agent_state = (host.agent_update_state or "").strip().lower()
|
||||
if agent_state == "running":
|
||||
active = True
|
||||
status = payload.get("status") or "running"
|
||||
elif agent_state in ("success", "failed"):
|
||||
active = False
|
||||
status = payload.get("status") or agent_state
|
||||
else:
|
||||
status = payload.get("status") or host.agent_update_state or "unknown"
|
||||
active = status == "running"
|
||||
return {
|
||||
"active": active,
|
||||
"host_id": host.id,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"""Единый источник версии SAC (API, health, логи, OpenAPI)."""
|
||||
|
||||
APP_NAME = "Security Alert Center"
|
||||
APP_VERSION = "0.5.3"
|
||||
APP_VERSION = "0.5.4"
|
||||
APP_VERSION_LABEL = f"{APP_NAME} v.{APP_VERSION}"
|
||||
|
||||
Reference in New Issue
Block a user