Enhance backend loading diagnostics and remount logic
- Introduced a new `loading_fail_sec` parameter in the `wait_backend_idle` function to handle prolonged loading states, improving error handling for backend readiness. - Updated the `ensure_dlbackend_bind` function to stop SwarmUI before remounting, preventing target busy errors and ensuring consistent data mounts. - Enhanced the `recover_errored_backends` function to account for the new remount logic, improving backend recovery processes. - Refactored tests to validate the new loading failure conditions and ensure proper handling of backend states during diagnostics.
This commit is contained in:
+37
-1
@@ -208,17 +208,21 @@ def wait_backend_idle(
|
||||
poll_every: float = 15.0,
|
||||
errored_fail_sec: float = 120.0,
|
||||
disabled_fail_sec: float = 90.0,
|
||||
loading_fail_sec: float = 900.0,
|
||||
) -> None:
|
||||
"""Block until SwarmUI backends are ready (status=running, no queue).
|
||||
|
||||
Note: SwarmUI ``idle`` means suspended backends (cannot generate).
|
||||
Ready-to-use is ``running``. Sustained ``errored`` / ``disabled`` fail-fasts.
|
||||
Ready-to-use is ``running``. Sustained ``errored`` / ``disabled`` / long
|
||||
``loading`` fail-fasts.
|
||||
"""
|
||||
deadline = time.time() + timeout
|
||||
log("жду ready backend (running)…")
|
||||
last = ""
|
||||
errored_since: float | None = None
|
||||
disabled_since: float | None = None
|
||||
loading_since: float | None = None
|
||||
last_loading_note = 0.0
|
||||
pretty = {
|
||||
"BUSY backend=loading (Comfy стартует)": "… Comfy стартует",
|
||||
"BUSY backend=some_loading (Comfy стартует)": "… Comfy стартует (часть бэкендов)",
|
||||
@@ -242,6 +246,38 @@ def wait_backend_idle(
|
||||
out = f"WAIT ssh: {exc}"
|
||||
line = out.splitlines()[-1] if out else "WAIT empty"
|
||||
shown = pretty.get(line, line)
|
||||
if "BUSY backend=loading" in line or "BUSY backend=some_loading" in line:
|
||||
now = time.time()
|
||||
if loading_since is None:
|
||||
loading_since = now
|
||||
elapsed = int(now - loading_since)
|
||||
shown = f"… Comfy стартует ({elapsed // 60}м {elapsed % 60}с)"
|
||||
if now - last_loading_note >= 60:
|
||||
last_loading_note = now
|
||||
try:
|
||||
j = run_ssh(
|
||||
cfg,
|
||||
host,
|
||||
"sudo -n journalctl -u swarmui -n 8 --no-pager -o cat 2>/dev/null "
|
||||
"| tail -n 8 || true",
|
||||
check=False,
|
||||
timeout=25,
|
||||
).strip()
|
||||
if j:
|
||||
for jl in j.splitlines()[-4:]:
|
||||
log(f" journal: {jl[:160]}")
|
||||
except Exception:
|
||||
pass
|
||||
if elapsed >= loading_fail_sec:
|
||||
collect_swarm_diagnostics(cfg, host, log)
|
||||
raise CloudError(
|
||||
f"backend=loading уже {elapsed} с — похоже завис "
|
||||
"(часто FrontendVersion / pip / сеть). Диагностика выше. "
|
||||
"Попробуй gpu-rent up снова или Server → Backends → Restart."
|
||||
)
|
||||
else:
|
||||
loading_since = None
|
||||
|
||||
if shown != last:
|
||||
log(shown)
|
||||
last = shown
|
||||
|
||||
Reference in New Issue
Block a user