Skip to content

Support arbitrary network driver options in wslc network create#40859

Open
beena352 wants to merge 5 commits into
microsoft:masterfrom
beena352:user/beenachauhan/feat/wslc-network-arbitrary-driver-opts
Open

Support arbitrary network driver options in wslc network create#40859
beena352 wants to merge 5 commits into
microsoft:masterfrom
beena352:user/beenachauhan/feat/wslc-network-arbitrary-driver-opts

Conversation

@beena352

@beena352 beena352 commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Summary of the Pull Request

Adds support for passing arbitrary driver options through to Docker when creating networks with wslc network create. Previously, only Internal, Subnet, and Gateway were recognized - any other option was silently dropped. Now unknown keys are forwarded to Docker and round-tripped through wslc network inspect. Case-mismatches of the three reserved keys (e.g., internal instead of Internal) are still rejected with a clear error.

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

Problem: wslc network create --opt my.abc.key=mygod silently dropped the option, it never reached Docker and network inspect showed no trace of it. Docker itself supports arbitrary driver options on networks; wslc should too.
Changes:
docker_schema.h- Added Options field to CreateNetwork and Network structs (same pattern already used by Volume).
wslc_schema.h- Added Options field to the output Network struct so inspect can surface them.
WSLCNetworkMetadata.h- Added Options to NetworkEntry cache.
WSLCSession.cpp: Changed validation from "reject all unknown keys" to "reject only case-mismatches of reserved keys" (Internal, Subnet, Gateway).
Forwards non-reserved driver opts into request.Options for Docker.
Copies Options from Docker's inspect response into the session cache.
Surfaces Options in InspectNetwork output.
Added Options copy in RecoverExistingNetworks so custom opts survive session restart.
WSLCTests.cpp:
Updated NetworkCreateInvalidDriverAndOptionTest- removed "foo" from rejection list (it's now a valid pass-through key).
New NetworkCreateWithArbitraryDriverOptsTest- creates with two custom opts, inspects and verifies they round-trip.
Extended NetworkSessionRecoveryTest- verifies custom opts survive session recovery.

Validation Steps Performed

Copilot AI review requested due to automatic review settings June 19, 2026 21:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR extends WSLC network management to support arbitrary Docker network driver options end-to-end (create → inspect JSON output → session recovery), while still treating a small set of reserved keys (Internal, Subnet, Gateway) as typed inputs with strict casing to avoid silent misinterpretation.

Changes:

  • Allow non-reserved DriverOpts to pass through to Docker’s CreateNetwork.Options, while rejecting case-mismatches for reserved keys.
  • Persist and surface network Options in WSLC’s in-memory metadata and JSON schema (wslc_schema::Network), including after session recovery.
  • Add/adjust Windows tests to validate arbitrary options round-trip and recovery behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/windows/WSLCTests.cpp Updates invalid-option expectations (case-mismatch only for reserved keys) and adds coverage for arbitrary driver options + recovery persistence.
src/windows/wslcsession/WSLCSession.cpp Implements reserved-key case-mismatch validation, forwards non-reserved options to Docker, and stores/returns Options on inspect and recovery.
src/windows/wslcsession/WSLCNetworkMetadata.h Extends the cached network entry to include Options.
src/windows/inc/wslc_schema.h Adds optional Options to WSLC inspect-network JSON schema.
src/windows/inc/docker_schema.h Adds optional Options to Docker network create/inspect schema used by the client.

@beena352 beena352 changed the title Support arbitrary network driver options in wslc create/inspect/recovery Support arbitrary network driver options in wslc network create Jun 19, 2026
@beena352 beena352 requested a review from Copilot June 19, 2026 21:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 5 out of 5 changed files in this pull request and generated 2 comments.

Comment thread src/windows/wslcsession/WSLCSession.cpp
Comment thread src/windows/wslcsession/WSLCSession.cpp

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 6 out of 6 changed files in this pull request and generated no new comments.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 6 out of 6 changed files in this pull request and generated no new comments.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 6 out of 6 changed files in this pull request and generated no new comments.

@beena352 beena352 marked this pull request as ready for review June 19, 2026 22:35
@beena352 beena352 requested a review from a team as a code owner June 19, 2026 22:35
Copilot AI review requested due to automatic review settings June 19, 2026 22:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 6 out of 6 changed files in this pull request and generated 1 comment.

Comment thread localization/strings/en-US/Resources.resw
<data name="MessageWslcInvalidNetworkDriverOption" xml:space="preserve">
<value>Unsupported network driver option: '{}'</value>
<comment>{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment>
<value>Network driver option '{}' is case-sensitive. Use the exact casing: Internal, Subnet, or Gateway.</value>

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.

How does docker the docker API react if it's passed these options with the wrong casing ? Does it just ignore them ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, Docker just silently accepts them. I disabled our validation temporarily and tested with --opt internal=true --opt subnet=172.55.0.0/16 --opt gateway=172.55.0.1 - all lowercase. Our InspectNetwork is a direct HTTP GET to Docker's /networks/{id} endpoint (deserialized 1:1), and it shows:
Internal: false (typed field never got set)
Subnet: 172.18.0.0/16, Gateway: 172.18.0.1 (Docker picked its own defaults)
Options: {"internal": "true", "subnet": "172.55.0.0/16", "gateway": "172.55.0.1"} (stored but doing nothing)
So from Docker's side, the lowercase keys just end up as inert entries in the Options map - the network gets created but is silently broken. That's why we reject the case mismatch up front.
image

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.

Ok in that case I think we should match their behavior. From a UX perspective I think the best way to this would be to implement the CLI options for these values that docker has (--internal, gateway , ...) and not to any specific casing check in the service

…eenachauhan/feat/wslc-network-arbitrary-driver-opts
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.

3 participants