Skip to content

fix(bay): 修复 Docker bind Cargo 目录处理 - #28

Draft
RhoninSeiei wants to merge 2 commits into
AstrBotDevs:mainfrom
RhoninSeiei:fix/docker-bind-cargo-local-path
Draft

fix(bay): 修复 Docker bind Cargo 目录处理#28
RhoninSeiei wants to merge 2 commits into
AstrBotDevs:mainfrom
RhoninSeiei:fix/docker-bind-cargo-local-path

Conversation

@RhoninSeiei

@RhoninSeiei RhoninSeiei commented Jul 15, 2026

Copy link
Copy Markdown

修改内容

  • Docker bind Cargo 通过 Bay 容器内的挂载根目录创建、检查和删除。
  • 返回给 Docker daemon 的仍是宿主机绝对目录。
  • 仅接受挂载根目录的直接子目录,并校验 bay-cargo- 名称前缀。
  • 拒绝根目录、目录外路径和符号链接,避免误删或引用错误目录。

问题原因

Bay 运行在容器内时,Docker daemon 使用宿主机目录,Bay 进程只能访问映射后的容器目录。旧实现使用宿主机目录执行本地文件操作,因此 bind Cargo 创建和清理会失败。

验证

  • 专项单元测试:21 passed
  • 生产组合分支单元测试:525 passed
  • Ruff:通过
  • 实际 Docker bind Cargo 创建、浏览器沙盒运行和级联清理均通过

Summary by Sourcery

Ensure Docker bind cargo volumes are created, checked, and deleted via Bay's container-mounted cargo root while still returning host-side paths to the Docker daemon.

Bug Fixes:

  • Fix bind cargo operations failing when Bay runs inside a container by mapping host bind paths to the container's mounted cargo root before performing filesystem actions.
  • Prevent accidental deletion or misuse of directories by rejecting non-cargo paths, paths outside the configured host root, and symbolic links during bind cargo handling.

Tests:

  • Add unit tests covering bind cargo creation, existence checks, deletion via the container mount, and validation of invalid or out-of-root paths.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors volume management in the Docker driver to resolve and map cargo bind paths locally through Bay's mounted path instead of directly using host paths. It introduces a helper method _local_cargo_path to validate paths (ensuring they are within the configured host root, start with the correct prefix, and are not symbolic links) and updates create_volume, delete_volume, and volume_exists to use this local mapping. Unit tests have been added to verify these changes. I have no additional feedback to provide as there are no review comments.

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.

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.

1 participant