Enhance backend management and performance tuning
- Introduced remounting logic for data directories to ensure correct bindings before restarting services, improving reliability during performance tuning. - Added functions to sanitize and ensure absolute paths for backend scripts, preventing issues with relative paths in bind mounts. - Enhanced the `patch_backends_extra_args` function to clean up corrupted entries and ensure proper configuration of backend parameters. - Updated tests to validate the new sanitization and path handling functionalities, ensuring robustness in backend management.
This commit is contained in:
+48
-4
@@ -178,12 +178,36 @@ def _bind_access(
|
||||
clock.mark("Idle", log)
|
||||
try:
|
||||
if tune_swarm_perf(cfg, ip, log):
|
||||
# git reset / prior boots can drop binds; remount before restart.
|
||||
run_ssh(
|
||||
cfg,
|
||||
ip,
|
||||
"sudo -n bash -c '"
|
||||
"for p in dlbackend Data Models Output; do "
|
||||
"src=/mnt/swarm_data/$p; dst=/opt/swarmui/$p; "
|
||||
"mkdir -p \"$src\" \"$dst\"; "
|
||||
"cur=$(findmnt -n -o SOURCE --target \"$dst\" 2>/dev/null || true); "
|
||||
"if [[ \"$cur\" != \"$src\" ]]; then "
|
||||
"umount \"$dst\" 2>/dev/null || umount -l \"$dst\" 2>/dev/null || true; "
|
||||
"mount --bind \"$src\" \"$dst\" || true; "
|
||||
"echo remounted $dst; "
|
||||
"fi; "
|
||||
"done'",
|
||||
check=False,
|
||||
timeout=60,
|
||||
)
|
||||
log("systemctl restart swarmui (perf ExtraArgs)")
|
||||
run_ssh(cfg, ip, "sudo -n systemctl restart swarmui", timeout=120)
|
||||
try:
|
||||
wait_backend_idle(cfg, ip, log)
|
||||
except CloudError as exc:
|
||||
log(f"ready after perf: {exc}")
|
||||
log(f"ready after perf: {exc} — recover backends")
|
||||
try:
|
||||
ensure_swarm_comfy_installed(cfg, ip, log)
|
||||
wait_backend_idle(cfg, ip, log)
|
||||
except Exception as exc2:
|
||||
log(f"recover after perf: {exc2}")
|
||||
raise exc from exc2
|
||||
else:
|
||||
log("perf tune: restart не нужен")
|
||||
except Exception as exc:
|
||||
@@ -314,8 +338,26 @@ def cmd_up(
|
||||
state.server_id = existing.id
|
||||
state.server_name = getattr(existing, "name", None)
|
||||
if status == "ACTIVE":
|
||||
if state.bootstrapped and state.floating_ip:
|
||||
# Warm re-up: skip git pull/stop cascade unless --update.
|
||||
# Prefer FIP from state; may still need ensure below.
|
||||
fip = state.floating_ip
|
||||
# Warm if local state says so, OR VM still has bootstrap marker
|
||||
# (local bootstrapped often cleared on stop while disk/VM remain).
|
||||
vm_warm = False
|
||||
if fip and not (state.bootstrapped and state.floating_ip):
|
||||
try:
|
||||
if probe_ssh(cfg, fip, attempts=1) == "ok":
|
||||
probe = run_ssh(
|
||||
cfg,
|
||||
fip,
|
||||
"test -f /opt/swarmui/.gpu-rent-bootstrapped && echo yes || echo no",
|
||||
check=False,
|
||||
timeout=20,
|
||||
).strip()
|
||||
vm_warm = probe.endswith("yes") or probe == "yes"
|
||||
except Exception:
|
||||
vm_warm = False
|
||||
|
||||
if (state.bootstrapped and state.floating_ip) or vm_warm:
|
||||
if update is None:
|
||||
do_update = False
|
||||
log(
|
||||
@@ -324,6 +366,9 @@ def cmd_up(
|
||||
)
|
||||
else:
|
||||
do_update = update
|
||||
if vm_warm and not state.bootstrapped:
|
||||
log("warm: маркер на VM — восстанавливаю local bootstrapped")
|
||||
state.bootstrapped = True
|
||||
log("сервер уже ACTIVE — второй GPU не создаём")
|
||||
state.phase = "bootstrapping"
|
||||
save_state(state)
|
||||
@@ -331,7 +376,6 @@ def cmd_up(
|
||||
return state
|
||||
|
||||
# Bootstrap не завершён: почти всегда VM без authorized_keys.
|
||||
fip = state.floating_ip
|
||||
if not fip:
|
||||
try:
|
||||
fip, fip_id = ensure_floating_ip(
|
||||
|
||||
Reference in New Issue
Block a user