Skip to content

wslc: add network create, delete, and list#40179

Draft
beena352 wants to merge 6 commits intomicrosoft:feature/wsl-for-appsfrom
beena352:user/beenachauhan/network-crud
Draft

wslc: add network create, delete, and list#40179
beena352 wants to merge 6 commits intomicrosoft:feature/wsl-for-appsfrom
beena352:user/beenachauhan/network-crud

Conversation

@beena352
Copy link
Copy Markdown

@beena352 beena352 commented Apr 14, 2026

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

  • Closes: Link to issue #xxx
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

  • Adds CreateNetwork, DeleteNetwork, and ListNetworks to the IWSLCSession COM interface, following the existing volume API pattern
  • New IDL types: WSLCNetworkOptions (with Labels and a JSON Options string) and WSLCNetworkInformation
  • Docker schema additions: IPAMConfig, IPAM, CreateNetwork, CreateNetworkResponse, Network
  • New file: WSLCNetworkMetadata.h for label constant, driver constant, reserved name validation, and NetworkEntry struct
  • Only the bridge driver is supported; Docker reserved names (bridge, host, none) are rejected
  • Options are passed as a JSON string to support mixed types (e.g., {"Internal": true, "Subnet": "172.28.0.0/16"}). Gateway requires Subnet

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.

Copilot AI review requested due to automatic review settings April 14, 2026 19:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 IWSLCSession with CreateNetwork, DeleteNetwork, ListNetworks and 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.

Comment thread src/windows/wslcsession/WSLCSession.cpp
Comment thread src/windows/wslcsession/WSLCSession.cpp
Comment thread src/windows/inc/docker_schema.h
Comment thread src/windows/wslcsession/WSLCSession.cpp
Comment thread src/windows/wslcsession/WSLCSession.cpp
Comment thread test/windows/WSLCTests.cpp Outdated
Comment thread test/windows/WSLCTests.cpp Outdated
Comment thread test/windows/WSLCTests.cpp
Comment thread test/windows/WSLCTests.cpp
Comment thread test/windows/WSLCTests.cpp
@beena352 beena352 requested a review from Copilot April 14, 2026 19:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 15 comments.

Comment thread src/windows/wslcsession/WSLCSession.cpp
Comment thread src/windows/wslcsession/WSLCSession.cpp
Comment thread src/windows/wslcsession/WSLCSession.cpp
Comment thread src/windows/wslcsession/WSLCSession.cpp
Comment thread src/windows/wslcsession/WSLCSession.cpp
Comment thread test/windows/WSLCTests.cpp Outdated
Comment thread test/windows/WSLCTests.cpp Outdated
Comment thread test/windows/WSLCTests.cpp Outdated
Comment thread test/windows/WSLCTests.cpp Outdated
Comment thread test/windows/WSLCTests.cpp Outdated
@beena352 beena352 requested a review from Copilot April 14, 2026 20:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Comment thread src/windows/wslcsession/WSLCSession.cpp Outdated
Comment thread src/windows/wslcsession/WSLCSession.cpp
Comment thread src/windows/wslcsession/WSLCSession.cpp
Comment thread src/windows/wslcsession/WSLCSession.cpp
@beena352 beena352 marked this pull request as ready for review April 14, 2026 20:56
@beena352 beena352 requested a review from a team as a code owner April 14, 2026 20:56
Copilot AI review requested due to automatic review settings April 14, 2026 20:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Comment thread src/windows/inc/docker_schema.h
Comment thread src/windows/wslcsession/WSLCSession.cpp
Comment thread src/windows/wslcsession/WSLCSession.cpp
Comment thread src/windows/wslcsession/WSLCSession.cpp
{
try
{
auto options = nlohmann::json::parse(Options->Options);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 */")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: I recommend validating the error message here (same for other customized error messages)

@beena352 beena352 marked this pull request as draft April 16, 2026 03:40
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.

4 participants