fix(node2): Fix router_healthy initialization in get_dagi_router_agents
- Initialize router_healthy as None instead of False - Use bool() to ensure proper boolean conversion - Add info logging for debugging - This ensures cached router_healthy=True is properly used
This commit is contained in:
@@ -4573,17 +4573,17 @@ async def get_dagi_router_agents(node_id: str):
|
||||
|
||||
# First, try to get router health from node_cache (populated by node-guardian)
|
||||
# This is preferred for remote nodes (like NODE2) where direct connection may not work
|
||||
router_healthy = False
|
||||
router_healthy = None
|
||||
try:
|
||||
metrics = await repo_city.get_node_metrics(node_id)
|
||||
if metrics and metrics.get("router_healthy") is not None:
|
||||
router_healthy = metrics.get("router_healthy", False)
|
||||
logger.debug(f"Using router_healthy from node_cache for {node_id}: {router_healthy}")
|
||||
router_healthy = bool(metrics.get("router_healthy", False))
|
||||
logger.info(f"Using router_healthy from node_cache for {node_id}: {router_healthy}")
|
||||
except Exception as e:
|
||||
logger.debug(f"Failed to get cached router health for {node_id}: {e}")
|
||||
|
||||
# Fallback: try direct health check (only works for local nodes like NODE1)
|
||||
if router_healthy is False:
|
||||
if router_healthy is None:
|
||||
endpoints = await repo_city.get_node_endpoints(node_id)
|
||||
base_url = endpoints.get("router_url")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user