fix(automation): 被重启打断的轮次记为 interrupted,不再混进 failed
部署重建容器会打断正在跑的作业,那轮永远写不回结果,由启动时的 cleanup_orphan_runs 收尾。之前收尾成 failed,于是页面上一片红 —— 但这并不是 作业本身的失败:账号侧的 CK 一个没丢(旧 Cookie 已保留),被中断的账号也会按 退避自动重试。混在 failed 里会掩盖真正的失败(如 SQL 语法错误)。 改为独立状态 interrupted,前端用中性灰显示「被中断」,与红色的「失败」区分开。
This commit is contained in:
@@ -617,7 +617,7 @@ class TestOrphanRunCleanup(_Base):
|
||||
self.session.refresh(stale)
|
||||
self.session.refresh(done)
|
||||
assert cleaned == 1
|
||||
assert stale.status == "failed"
|
||||
assert stale.status == "interrupted"
|
||||
assert stale.finished_at is not None
|
||||
assert stale.message == "服务重启中断"
|
||||
assert done.status == "success" # 已完成的不受影响
|
||||
|
||||
@@ -140,7 +140,10 @@ def cleanup_orphan_runs(db: Session, message: str = "服务重启中断") -> int
|
||||
"""
|
||||
orphans = db.query(AutomationRun).filter(AutomationRun.status == "running").all()
|
||||
for run in orphans:
|
||||
run.status = "failed"
|
||||
# 用 interrupted 而不是 failed:这不是作业本身的失败(账号侧 CK 没丢、
|
||||
# 被中断的也会按退避重试),只是进程没了导致那轮没跑完。混进 failed
|
||||
# 会让页面一片红,掩盖真正的失败。
|
||||
run.status = "interrupted"
|
||||
run.finished_at = datetime.now(UTC)
|
||||
run.message = message
|
||||
if orphans:
|
||||
|
||||
@@ -31,6 +31,9 @@ import { formatTime } from "../utils/time";
|
||||
const STATUS_TAG: Record<string, { color: string; text: string }> = {
|
||||
success: { color: "green", text: "成功" },
|
||||
failed: { color: "red", text: "失败" },
|
||||
// 被部署/重启打断:不是作业本身的失败(CK 没丢,会自动重试),
|
||||
// 用中性色,避免和真失败混在一起。
|
||||
interrupted: { color: "default", text: "被中断" },
|
||||
running: { color: "blue", text: "执行中" },
|
||||
skipped: { color: "default", text: "已跳过" },
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user