fix(router): address greptile review comments

- Narrow cooldown safety-net bypass: only fires when allowed_fails_policy
  is set (cooldown is health-check driven). Without a policy, cooldowns
  are from real request failures and must not be bypassed.
- Restore cooldown deployments DEBUG log that was accidentally removed.
- Fix test_health TypeError: move exception extraction to a separate
  exceptions_by_model_id dict returned alongside endpoints, so exception
  objects never appear in the endpoint dicts that get JSON-serialized
  by the /health response.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Sameer Kankute 2026-04-02 18:43:41 +05:30
parent fc155c7bfa
commit 5850b1130e
No known key found for this signature in database

View file

@ -9079,12 +9079,21 @@ class Router:
cooldown_deployments = await _async_get_cooldown_deployments(
litellm_router_instance=self, parent_otel_span=parent_otel_span
)
if verbose_router_logger.isEnabledFor(logging.DEBUG):
verbose_router_logger.debug(f"cooldown deployments: {cooldown_deployments}")
_pre_cooldown_deployments = healthy_deployments
healthy_deployments = self._filter_cooldown_deployments(
healthy_deployments=healthy_deployments,
cooldown_deployments=cooldown_deployments,
)
if not healthy_deployments and self.enable_health_check_routing:
# Safety net: only bypass cooldown filter when health-check routing is
# driving cooldown (i.e. allowed_fails_policy is set). Without a policy,
# cooldowns are from real request failures and must not be bypassed.
if (
not healthy_deployments
and self.enable_health_check_routing
and self.allowed_fails_policy is not None
):
verbose_router_logger.warning(
"All deployments in cooldown via health-check routing, bypassing cooldown filter"
)
@ -9526,7 +9535,11 @@ class Router:
healthy_deployments=healthy_deployments,
cooldown_deployments=cooldown_deployments,
)
if not healthy_deployments and self.enable_health_check_routing:
if (
not healthy_deployments
and self.enable_health_check_routing
and self.allowed_fails_policy is not None
):
verbose_router_logger.warning(
"All deployments in cooldown via health-check routing, bypassing cooldown filter"
)