已关闭
[Enhancement] Port allocation utility should support range-based reservation and deterministic release on agent stop #52
张鑫宇创建于 6月15日关闭于 6月15日
openJiuwen-bot
6月15日 评论:
6月15日 评论:
欢迎来到 openJiuwen 社区
Hey @xinyu-jiuwen , 感谢你对社区的贡献.
机器人使用手册
有关指令的使用,可以点击 此处 查看详情。开发人员可以在每个PR或Issue下方评论特定指令来触发机器人任务。


6月15日 issue状态由 TODO 改变为 CLOSED
6月15日 关闭了 issue
Description
The
agent-runtimerepository includes a port allocation utility in its foundation shared libraries, but it lacks proper resource lifecycle management. When agents are frequently deployed and stopped (as is common in dev/test environments and CI pipelines), port conflicts can arise:0.0.0.0.stop()orteardown()lifecycle hooks of deployers don't explicitly call a port release method.Expected Behavior
Deployer.stop()orDeployer.teardown()is called, the port allocator should be notified to release the port back to the pool.RELEASINGstate for a configurable cooldown period (e.g., 30s) before being available for re-allocation, to avoid conflicts with lingering socket TIME_WAIT states.Suggested Approach
PortAllocatorinto a stateful manager:PortEntry(port, tenant_id, space_id, agent_id, status=IN_USE|RELEASING|FREE, released_at)allocate(tenant_id, space_id, agent_id) -> intrelease(agent_id) -> boolget_allocated(tenant_id) -> list[PortEntry]port_allocator.release(agent_id)inSubprocessDeployer.stop(),DockerDeployer.stop(), andK8sDeployer.stop()/api/v1/portsmanagement endpoint (admin-only) for inspecting and manually releasing portsRelated components
agent_runtime/common/utils/port.py— current port allocation logicagent_runtime/common/db/sqlite_handler.py— for port state persistenceagent_runtime/deployer/*.py— all strategy deployers need lifecycle wiringagent_runtime/api/routes.py— new admin endpointLabels
enhancement, good first issue