fix(proxy-node): tunnel 模式节点注册不再覆盖由连接管理的状态

register_node 对 tunnel 模式已有节点不再写 status 字段,
状态完全由 _update_tunnel_status 和 health_scheduler 管理,
避免心跳注册将已连接的 ONLINE 状态覆盖为 UNHEALTHY。
This commit is contained in:
fawney19
2026-02-26 13:38:08 +08:00
parent 61535dfb7e
commit 7e73e7fab2

View File

@@ -264,14 +264,13 @@ class ProxyNodeService:
)
else:
node = db.query(ProxyNode).filter(ProxyNode.ip == ip, ProxyNode.port == port).first()
# tunnel 模式注册时设为 UNHEALTHY等 WebSocket tunnel 真正连接后
# 由 _update_tunnel_status 设为 ONLINE非 tunnel 模式保持原逻辑
initial_status = ProxyNodeStatus.UNHEALTHY if tunnel_mode else ProxyNodeStatus.ONLINE
if node:
node.name = name
node.region = region
node.status = initial_status
# tunnel 模式:状态完全由 tunnel 连接管理_update_tunnel_status / health_scheduler
# 注册/心跳不干预;非 tunnel 模式照旧
if not tunnel_mode:
node.status = ProxyNodeStatus.ONLINE
node.last_heartbeat_at = now
node.heartbeat_interval = heartbeat_interval
node.tunnel_mode = tunnel_mode
@@ -292,7 +291,8 @@ class ProxyNodeService:
ip=ip,
port=port,
region=region,
status=initial_status,
# tunnel 模式新节点:等 tunnel 连接后才上线
status=ProxyNodeStatus.UNHEALTHY if tunnel_mode else ProxyNodeStatus.ONLINE,
registered_by=registered_by,
last_heartbeat_at=now,
heartbeat_interval=heartbeat_interval,