fix(docker): allocate session networks from configured pool - #29
Open
evergardener wants to merge 1 commit into
Open
fix(docker): allocate session networks from configured pool#29evergardener wants to merge 1 commit into
evergardener wants to merge 1 commit into
Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The subnet selection currently has a TOCTOU race between
networks.list()andnetworks.create(); consider catching Docker errors for overlapping subnets and retrying with the next candidate subnet rather than failing the whole session creation. _used_docker_subnetsassumesnetworksis a list of dicts, but the Docker SDK commonly returnsNetworkobjects; to make this more robust, consider handling both objects (via.attrs) and plain dicts when extracting IPAM config.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The subnet selection currently has a TOCTOU race between `networks.list()` and `networks.create()`; consider catching Docker errors for overlapping subnets and retrying with the next candidate subnet rather than failing the whole session creation.
- `_used_docker_subnets` assumes `networks` is a list of dicts, but the Docker SDK commonly returns `Network` objects; to make this more robust, consider handling both objects (via `.attrs`) and plain dicts when extracting IPAM config.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
10.252.0.0/16split into/24session networksMotivation
On Docker Desktop, automatic bridge allocation can select
192.168.0.0/20, which overlaps common physical192.168.x.xLANs and breaks container access to LAN dependencies. Explicit per-session IPAM keeps sandbox isolation while avoiding Docker Desktop's opaque default pool selection.Validation
cd pkgs/bay && uv sync --frozencd pkgs/bay && uv run pytest tests/unit/drivers/test_docker_session_network.py -v --tb=short— 9 passedcd pkgs/bay && uv run ruff check app/config.py app/drivers/docker/docker.py tests/unit/drivers/test_docker_session_network.py— passedcd pkgs/bay && uv run pytest tests/unit -v --tb=short— 365 passed, 121 errors. The errors are outside this change and occur during async SQLAlchemy test setup becausegreenletis not installed by the current locked dependency environment. The focused IPAM tests pass using the same environment.Scope
This change only affects newly created Docker session networks. It does not alter existing networks, Cargo paths, deployment secrets, or persistent data.
Summary by Sourcery
Configure deterministic Docker session bridge networks from a validated private address pool and avoid overlapping existing Docker networks.
New Features:
Enhancements:
Tests: