fix: log sidecar switch failures + fix scoping bug in proxy handler
Two changes to debug the fallback-to-LXC issue: 1. Added debug logging on switch failure: prints the profile name, sidecar response status, and error message. Also calls circuit_record_failure() so subsequent requests don't wait the full 120-second timeout before falling back. 2. Fixed scoping bug: sidecar_status was only defined inside the else branch of the circuit breaker check. Initialized to None at function scope alongside target_url and error to prevent NameError when circuit is open.
This commit is contained in:
parent
f2e62f60e6
commit
5c1753dfef
8
main.py
8
main.py
@ -401,6 +401,7 @@ async def proxy(
|
||||
# ── Determine target URL ──────────────────────────────────────────────
|
||||
target_url: Optional[str] = None
|
||||
error: Optional[str] = None
|
||||
sidecar_status = None
|
||||
|
||||
# Circuit breaker check
|
||||
if not await circuit_breaker_check():
|
||||
@ -487,6 +488,13 @@ async def proxy(
|
||||
target_url = f"{MAIN_PC_BASE}/{path}"
|
||||
else:
|
||||
error = "switch_failed"
|
||||
circuit_record_failure()
|
||||
print(
|
||||
f"SWITCH FAILED: profile={requested_model}, "
|
||||
f"sidecar_status={switch_result.get('status')}, "
|
||||
f"message={switch_result.get('message', '(no message)')}",
|
||||
flush=True,
|
||||
)
|
||||
except Exception as e:
|
||||
circuit_record_failure()
|
||||
error = f"switch_error: {str(e)}"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user