fix(bay): 修复预热沙盒卡住与多容器误判 - #25
Conversation
There was a problem hiding this comment.
Code Review
This pull request improves multi-container runtime group health checks and cleanup handling, updates the Kubernetes driver to wait for pod deletion during destruction, and refactors the warm pool scheduler's reconciliation logic. Feedback on the scheduler changes highlights a potential issue where unconditionally requeuing all pending sandboxes could disrupt active, healthy warmup tasks; the reviewer suggests only requeuing sandboxes that have no active session or whose session has failed or stopped.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| pending_rows = [ | ||
| (sandbox, session) for sandbox, session in warm_rows if sandbox.warm_state is None | ||
| ] |
There was a problem hiding this comment.
无条件地重新排队所有待处理沙盒(即 sandbox.warm_state is None)会导致那些当前正在进行中且正常的预热沙盒(例如会话处于 STARTING 或 RUNNING 状态但尚未被标记为 AVAILABLE)也被重新排队。这可能会导致重复的预热任务、冗余的驱动程序/数据库查询以及潜在的并发竞争问题。
我们应该仅在待处理沙盒没有活动会话(即 session is None)或者其会话已失败或已停止时,才重新排队它们。
pending_rows = [
(sandbox, session)
for sandbox, session in warm_rows
if sandbox.warm_state is None
and (
session is None
or session.observed_state in (SessionStatus.FAILED, SessionStatus.STOPPED)
)
]There was a problem hiding this comment.
已修复。de8a09b 仅对无会话或 FAILED、STOPPED 会话的 pending 记录重新入队,并新增 STARTING、RUNNING 会话保持现状的参数化测试;相关 20 项测试通过。
| from app.drivers.base import ContainerStatus | ||
| from app.models.sandbox import Sandbox, WarmState | ||
| from app.models.session import Session, SessionStatus | ||
| from app.models.session import Session |
There was a problem hiding this comment.
已同步处理。de8a09b 恢复 SessionStatus 导入,并用于筛选允许重新入队的失败或停止会话。
|
补充处理了调度器与预热任务并发时的状态写回问题:调度器将数据库状态重置为 v0.4.0 实际运行验证中,失效 Ship 自动恢复,下一轮调度统计为 |
修改内容
warm_state IS NULL条件更新写回available,避免并发调度留下永久待处理状态,同时保留已领取和已退役状态。问题原因
预热队列只保存在进程内,任务失败或进程重启后可能长期停留在待处理状态。运行时探测曾把部分存在的多容器组视为健康,清理失败后又会丢失再次处理所需的信息。调度器重置状态与预热任务同时执行时,任务还可能读取旧的 ORM 对象并跳过可用状态写回。
验证
38 passed525 passedavailable=1、pending=0