wslc: add network create, delete, and list#40179
wslc: add network create, delete, and list#40179beena352 wants to merge 6 commits intomicrosoft:feature/wsl-for-appsfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds WSLC custom network management (create, delete, list) backed by the Docker Engine API, including COM/IDL surface area, persistence/recovery in the session, Docker schema bindings, and TAEF coverage.
Changes:
- Extend
IWSLCSessionwithCreateNetwork,DeleteNetwork,ListNetworksand add corresponding IDL structs/constants. - Implement network bookkeeping (in-memory map + recovery via managed-label) and Docker HTTP client endpoints.
- Add docker schema types for network create/list and TAEF tests covering network CRUD and validation.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| test/windows/WSLCTests.cpp | Adds TAEF tests for network create/delete/list, options parsing, reserved name/driver validation, and session recovery. |
| src/windows/wslcsession/WSLCSession.h | Adds network methods to the session interface and introduces network lock/map + recovery hook. |
| src/windows/wslcsession/WSLCSession.cpp | Implements network CRUD/list, termination cleanup, and recovery of WSLC-managed networks. |
| src/windows/wslcsession/WSLCNetworkMetadata.h | Introduces constants (managed label/driver) and reserved-name validation helper + entry struct. |
| src/windows/wslcsession/DockerHTTPClient.h | Adds Docker client APIs for network create/remove/list. |
| src/windows/wslcsession/DockerHTTPClient.cpp | Implements HTTP transactions for Docker network endpoints. |
| src/windows/service/inc/wslc.idl | Adds IDL types for network options/info, new session methods, and a not-found HRESULT. |
| src/windows/inc/docker_schema.h | Adds JSON (de)serialization types for network create/list including IPAM fields. |
| localization/strings/en-US/Resources.resw | Adds user-facing localized strings for network errors and invalid options. |
| { | ||
| try | ||
| { | ||
| auto options = nlohmann::json::parse(Options->Options); |
There was a problem hiding this comment.
I think we should do something similar to #40181, where the caller passes in key value pairs that we then pass to the driver (in this case, docker)
There was a problem hiding this comment.
Also we should probably limit what keys we allow, for instance I don't think we should allow custom gateways just yet, because depending on the networking mode (virtionet vs NAT), this will either work, or break
There was a problem hiding this comment.
Just merged #40181, so you can use the KeyValuePair struct and ParseKeyValuePairs helper that I created for this purpose.
| cpp_quote("#define WSLC_E_CONTAINER_IS_RUNNING MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, WSLC_E_BASE + 6) /* 0x80040606 */") | ||
| cpp_quote("#define WSLC_E_SESSION_RESERVED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, WSLC_E_BASE + 7) /* 0x80040607 */") | ||
| cpp_quote("#define WSLC_E_INVALID_SESSION_NAME MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, WSLC_E_BASE + 8) /* 0x80040608 */") | ||
| cpp_quote("#define WSLC_E_NETWORK_NOT_FOUND MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, WSLC_E_BASE + 9) /* 0x80040609 */") |
There was a problem hiding this comment.
This new error should be added to g_commonErrors, in wslutil.cpp
| options.Driver = "overlay"; | ||
| options.Options = nullptr; | ||
|
|
||
| VERIFY_ARE_EQUAL(E_INVALIDARG, m_defaultSession->CreateNetwork(&options)); |
There was a problem hiding this comment.
nit: I recommend validating the error message here (same for other customized error messages)
Summary of the Pull Request
Adds WSLC custom network management (create, delete, list) via the Docker Engine API. This is the first PR in the network support series, subsequent PRs will add inspect, container-on-network, SDK, and CLI support.
PR Checklist
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed
Tests covering: CRUD lifecycle, duplicate name handling, delete-not-found, subnet/gateway options, internal network flag, user labels, invalid driver/name/options/JSON, session recovery, and multi-network create/list/delete.