models on tracker

This commit is contained in:
Dobromir Popov
2026-07-12 02:44:12 +03:00
parent 95d79a0a16
commit 9a1b15c020
7 changed files with 131 additions and 11 deletions

View File

@@ -631,6 +631,21 @@ def _registration_display_fields(node_name: str | None) -> dict[str, str]:
return {"friendly_name": name}
def _tracker_http_error_message(exc: urllib.error.HTTPError) -> str:
"""Describe an HTTP rejection from the tracker, including its JSON error."""
detail = exc.reason or "request rejected"
try:
payload = json.loads(exc.read().decode("utf-8", errors="replace"))
error = payload.get("error") if isinstance(payload, dict) else None
if isinstance(error, dict):
detail = error.get("message") or error.get("code") or detail
elif error:
detail = error
except Exception:
pass
return f"Tracker rejected shard assignment (HTTP {exc.code}): {detail}"
def run_startup(
tracker_url: str,
port: int = 0,
@@ -1108,6 +1123,8 @@ def run_startup(
})
try:
assignment = _get_json(f"{tracker_url}/v1/nodes/assign?{assign_qs}")
except urllib.error.HTTPError as exc:
raise RuntimeError(_tracker_http_error_message(exc)) from exc
except urllib.error.URLError as exc:
print(f" ERROR: Cannot reach tracker at {tracker_url}: {exc}", file=sys.stderr, flush=True)
raise