已开启
feat: Design Scheme for Sandbox_tttp Adaptation to ADX YAML Contract Interface #86
WanYihui创建于 3 天前
feat: Design Scheme for Sandbox_tttp Adaptation to ADX YAML Contract Interface #86
已开启
合并受阻
atomgit-bot
3 天前 评论:
3 天前 评论:
变更摘要
本 PR 围绕 Sandbox 适配 ADX YAML 契约接口进行改造,将原先私有的 /v1/sandbox/sandboxes 路由体系替换为两族契约端点:管理面 /api/sandbox/v1/sandboxes(create/delete,成功响应 Envelope 且 data 为 base64 编码 JSON,失败返回 ErrorEnvelope)与数据面 POST /direct/{instanceId}/invoke(单端点 action 分发,action 级失败以 HTTP 200 携带 error 字段返回)。sandbox_http.py 中新增 sandbox_api_kind() 统一判定路径归属,删除了旧的 SANDBOX_PREFIX、SANDBOX_ROUTES 与相关匹配函数;create 参数按契约字段收口并做位置迁移校验;sandbox.py 为命名实例固定 namespace 以保证后续 invoke 寻址一致;测试相应移除旧路由用例并改用 invoke 端点,conftest.py 补齐 yr.InvokeOptions 的顶层再导出。
主要改动
- 路由入口改为契约端点判定:
http_server.py各do_*分支不再比较SANDBOX_PREFIX,统一改用sandbox_api_kind(path)判定mgmt/invoke并转入_sandbox_api_request,新增前缀只需修改该函数。 - 管理面与数据面分离:
sandbox_http.py将原_dispatch_sandbox拆为_dispatch_mgmt与_invoke_request/_dispatch_invoke,新增_mgmt_envelope、_write_mgmt_error(_MGMT_ERROR_SYMBOLS提供符号码/重试/结果语义)以及_mgmt_allowed_methods,错误响应与成功响应均回显X-Request-Id。 - invoke action 白名单与参数适配:新增
INVOKE_ACTIONS(process.exec/process.run、file.read、file.write、file.list、file.search)及_invoke_exec、_invoke_file_read、_invoke_file_write、_invoke_file_list、_invoke_file_search,字段按契约转换(returncode→exit_code、二进制 read/write 使用 hex、目录条目经_to_contract_entry转换type/modified_time)。 - create 载荷按契约字段收口:
_build_sandbox_options改为接收契约 13 个字段,_MOVED_BODY_FIELDS校验旧顶层字段(sandbox_type→runtime、upstream/working_dir/user→extra_config、trace_id→X-Trace-ID头),新增tunnel(enabled/proxyPort)、rootfs/mounts翻译与snapshotId恢复实例分流,idle_timeout放宽为非负。 - 命名实例 namespace 固定:
sandbox/sandbox.py新增_DEFAULT_INSTANCE_NAMESPACE与_named_instance_namespace(),命名 create 时设置opt.namespace,使实例注册 id 与 invoke 端{ns}-{name}寻址方式一致。 - 测试与桩代码同步调整:
tests/conftest.py将yr.InvokeOptions改为复用yr.config.InvokeOptions;tests/executor/test_http_server.py删除旧/v1/sandbox/sandboxes路由用例,并发用例改用/direct/local/invoke并断言exit_code。


不准确?
atomgit-bot
3 天前 评论:
3 天前 评论:
代码审查
审查结论
- [建议]
executor/src/yr/agentexecutor/http_server.py:232fix: PUT 进入 sandbox 路由时未消费请求体也未断开 keep-alive - [建议]
executor/src/yr/agentexecutor/sandbox/sandbox.py:95fix: 命名实例 namespace 优先取运行时配置,与注释所述的 invoke 寻址值可能不一致 - [建议]
tests/executor/test_http_server.py:357test: 删除全部沙箱端点用例,新增 sandbox yaml 管理面/数据面无覆盖 - [建议]
executor/src/yr/agentexecutor/sandbox_http.py:682fix: rootfs 为字符串时 mounts 被静默丢弃 - [建议]
executor/src/yr/agentexecutor/sandbox_http.py:190fix: snapshotId 恢复分支绕过私有顶层字段校验,非法字段被静默忽略 - [建议]
executor/src/yr/agentexecutor/sandbox_http.py:620fix: create 请求读取 idle_timeout,与契约 idleTimeoutSeconds 命名不一致
| 类型 | 数量 |
|---|---|
| 🔴 阻塞 | 0 |
| 🟡 建议 | 6 |
💬 仅评论


不准确?
openJiuwen-bot
3 天前 评论:
3 天前 评论:
欢迎来到 openJiuwen 社区
Hey @pikachuwan , 感谢你对社区的贡献.
机器人使用手册
有关指令的使用,可以点击 此处 查看详情。开发人员可以在每个PR或Issue下方评论特定指令来触发机器人任务。


atomgit-bot
3 天前 评论:
3 天前 评论:
3 天前 添加了label:openJiuwen-cla/yes
此处折叠了69条消息 查看更多
2 小时前 删除了label:ci-failed
2 小时前 添加了label:ci-running
2 小时前 删除了label:ci-running
2 小时前 添加了label:ci-successful
Paired: GitHub #106 ↔ GitCode !86
What type of PR is this?
/kind feature



Self-checklist:(请自检,在[ ]内打上x,我们将检视你的完成情况,否则会导致pr无法合入)
Linked Closing Issues: