Enhance logging and timing in CLI and session operations

- Updated the `_print_checks` function to replace console prints with logging functions for better traceability.
- Introduced timing functionality in the `doctor`, `dry_run`, and `up` functions to log the duration of preflight checks.
- Modified the `wait_ssh` function to accept a logging callback, improving SSH wait feedback.
- Enhanced the `mark` method in `PhaseTimes` to log phase durations, aiding in performance analysis.
- Updated various remote scripts to ensure error messages are printed to stderr for better error handling.
This commit is contained in:
Leonid Pershin
2026-08-21 08:03:04 +03:00
parent 7756d0d4df
commit ccba40a228
16 changed files with 205 additions and 46 deletions
+11 -10
View File
@@ -88,8 +88,8 @@ def _bind_access(
if fip_id:
state.floating_ip_id = fip_id
save_state(state)
wait_ssh(cfg, ip)
clock.mark("SSH")
wait_ssh(cfg, ip, log=log)
clock.mark("SSH", log)
log(f"SSH {cfg.ssh_user}@{ip}")
state.phase = "bootstrapping"
save_state(state)
@@ -141,7 +141,7 @@ def _bind_access(
log("bootstrap: FULL llm-only — маркера data ready нет")
run_bootstrap(cfg, ip, log, update=update and swarm, light=light)
clock.mark("bootstrap")
clock.mark("bootstrap", log)
provision_vm(
cfg,
ip,
@@ -150,13 +150,13 @@ def _bind_access(
server_id=getattr(server, "id", None) or state.server_id,
update=update,
)
clock.mark("provision")
clock.mark("provision", log)
if swarm:
try:
wait_backend_idle(cfg, ip, log)
except CloudError as exc:
log(f"ready: {exc}")
clock.mark("Idle")
clock.mark("Idle", log)
try:
if tune_swarm_perf(cfg, ip, log):
log("systemctl restart swarmui (perf ExtraArgs)")
@@ -169,12 +169,12 @@ def _bind_access(
log("perf tune: restart не нужен")
except Exception as exc:
log(f"perf tune: {exc}")
clock.mark("perf")
clock.mark("perf", log)
try:
seed_swarmui_api_keys(cfg, ip, log)
except Exception as exc:
log(f"SwarmUI API keys: {exc}")
clock.mark("api-keys")
clock.mark("api-keys", log)
else:
log("ready: llm-only (без ожидания SwarmUI Idle)")
@@ -190,7 +190,7 @@ def _bind_access(
state.notes["stack_vm_error"] = str(exc)[:500]
save_state(state)
raise
clock.mark("verify")
clock.mark("verify", log)
try:
gpu_checks = verify_gpu_env(cfg, ip, log, timeout=600.0)
@@ -204,7 +204,7 @@ def _bind_access(
state.notes["gpu_env_error"] = str(exc)[:500]
save_state(state)
raise
clock.mark("gpu-env")
clock.mark("gpu-env", log)
try:
ensure_boot_snapshot(
@@ -243,7 +243,8 @@ def _bind_access(
state.notes["enable_swarmui"] = swarm
state.notes["up_timing"] = clock.summary_line()
save_state(state)
log(f"тайминг up: {clock.summary_line()}")
for line in clock.summary_lines():
log(line)
return state