Skip to content

fix(m8): Runner 安装包代理改走内网 OSS endpoint,消除 spot 公网流出 (#489) - #490

Merged
Shadow-Azure merged 2 commits into
mainfrom
agent/issue-489-dev-18bed0bf5aac
Dec 4, 2026
Merged

Shadow-Azure merged 2 commits into
mainfrom
agent/issue-489-dev-18bed0bf5aac

Conversation

@ZTGolem

@ZTGolem ZTGolem commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

This is by an automated agent, not a human.

问题

issue #489:12 月 OSS 账单前 3 天约 ¥42,其中约 ¥40 是公网流出。367 台 spot 实例每台经 /runner/v1/runner-tarball/<version>.tar.gz 下载约 228 MB 的 runner 包,而 runner_tarball() 用公网 endpoint 读取私有 OSS;按 ¥0.50/GB 约 ¥41.9,与账单吻合。

改动

  • backend/app/api/runners.py:runner_tarball() 改用 object_store_from_settings(settings, internal=True)。阿里云部署自动派生 -internal endpoint(S3_INTERNAL_ENDPOINT 可覆盖),非阿里云部署保持原 endpoint;spot 实例仍只访问 API 的 VPC 回调地址,不直连 OSS 内网。
  • tests/backend/test_runner_tarball.py:新增回归测试。公共 endpoint 指向 127.0.0.1:1(不可达),内网指向本地 S3 stub,断言 HTTP 200、完整内容与 Content-Length,证明实现没有回退公网。
  • .agents/flow/issues/m8-runner-tarball-internal-endpoint.*:补 flow issue 三件套(m8,P2,in-progress;成本优化,无功能阻塞),scope 覆盖上述文件。

验证

  • pytest tests/backend/test_runner_tarball.py:8 passed。
  • 本地全量 pytest:通过。
  • CI(head 372af6a,已 rebase 到 main 54e8ef1):8/8 通过,含 PostgreSQL 后端测试、docs、flow-offline、flow-online、deployment contract、web 与 runner 契约测试。
  • npm test、npm run verify:docs、npm run verify:flow、PR_TITLE=... node scripts/verify-flow.mjs --diff origin/main:通过。
  • API 冒烟(本地 uvicorn + S3 stub,代码 commit 6462974(rebase 前 e879861,代码树相同);公共 endpoint 保持不可达):4/4 passed。
# 场景 结果 细节
01 内网 endpoint 完整流式下载 PASS HTTP 200,3,670,035 B,sha256 c832c13f…,Content-Length 一致
02 缺少 Runner Token 拒绝下载 PASS HTTP 401,runner_token_invalid
03 不存在的版本返回 404 PASS HTTP 404,runner_tarball_not_found
04 非版本文件名返回 404 PASS HTTP 404,runner_tarball_not_found

冒烟环境:uvicorn app.main:app + 本地 S3 stub 作为 S3_INTERNAL_ENDPOINT,S3_ENDPOINT=http://127.0.0.1:1 故意不可达。冒烟测试脚本与 HTML 报告仅保留在本地,不提交仓库。

UI 证据

本 PR 只改后端 runner 安装包代理的 OSS 读取路径,不涉及任何前端页面,prototype 原型 UI 对比不适用,因此没有 before/after 截图。

部署后验证

This PR was produced by dsh-superagent under the ZTGolem account.

@ZTGolem ZTGolem added this to the 问题修复 milestone Dec 4, 2026
ZTGolem added a commit that referenced this pull request Dec 4, 2026
检视只读完成:5 文件 +119/-3,新增内网 endpoint 端到端回归。无阻断发现;内网故障回退公网列为取舍,真实链路与账单验收留到部署后。
runner_tarball() 之前用公网 endpoint 读取私有 OSS,367 台 spot 每台代理下载 228 MB 都产生一次公网流出。改为 internal=True:阿里云部署自动派生 -internal endpoint,非阿里云部署保持现有 endpoint;spot 仍只访问 API 的 VPC 回调地址。

新增回归测试:公共 endpoint 指向不可达地址,经内网 stub 完整流式下载,证明实现没有回退公网。
检视只读完成:5 文件 +119/-3,新增内网 endpoint 端到端回归。无阻断发现;内网故障回退公网列为取舍,真实链路与账单验收留到部署后。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants