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:
2026-07-08 12:30:14 +10:00
parent 253b80c500
commit 1ad01534f1
3 changed files with 44 additions and 4 deletions
+19 -3
View File
@@ -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,