Skip to content

ci: import a daily prepared WSL distribution in the Windows WSL smoke shard - #346338

Merged
Ladislau Szomoru (lszomoru) merged 1 commit into
mainfrom
lszomoru/agents/wsl-prepared-distro
Nov 5, 2026
Merged

Ladislau Szomoru (lszomoru) merged 1 commit into
mainfrom
lszomoru/agents/wsl-prepared-distro

Conversation

@lszomoru

@lszomoru Ladislau Szomoru (lszomoru) commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

The Windows smoke test shard with the WSL suite (Electron-Smoke (shard 1/3), 1ES pool) builds its WSL distribution from scratch in every run: it downloads the Ubuntu rootfs and the pinned Linux server, downloads and installs the apt packages (docker.io, krb5, squid-openssl, …) and pulls the dev container image. This prepares that distribution once a day and the shard imports it instead.

What changed

  • test/smoke/wslDevContainer.ps1 stays one script. Its build steps move into functions without changing their commands, and it gets a Prepare operation that builds the same distribution up to the pulled dev container image, stops dockerd, cleans and trims the disk, and exports the VHD with wsl --export --format vhd (then diskpart compact vdisk, best effort). Setup imports the VHD named by WSL_PREPARED_DISTRO_VHD with wsl --import-in-place under the run's distribution name, starts dockerd and runs the existing image, bind mount and non-root Docker checks. Without one, or when importing or starting it fails, it unregisters it and builds the distribution as before. The outputs, AddServer, Cleanup and Azure Pipelines are unchanged.
  • pr-workspace-images.yml: a new Windows (WSL distribution) job, which only runs on the daily schedule and on manual runs. It runs on the 1ES pool like the shard, as GitHub-hosted Windows runners intermittently freeze while WSL2 provisions a distribution (Windows hosted runner worker freezes during WSL2 provisioning; step timeouts never fire, job runs to the job cap with no logs actions/runner-images#14938). It runs Prepare and saves the VHD with actions/cache/save under wsl-distro-v1-Windows-<hash of wslDevContainer.ps1 and build/checksums/wsl.txt>-<run id>-<attempt>. The image jobs are unchanged.
  • pr-win32-test.yml: shard 1 restores the newest entry with that hash (restore-keys, continue-on-error) before it starts the background WSL setup (Optimize VS Code PR checks by skipping unnecessary tests and updating shards #346272), and passes the VHD in WSL_PREPARED_DISTRO_VHD.
  • The smoke test README and the smoke-tests skill describe it.

Things to look at

  • A commit that changes wslDevContainer.ps1 or build/checksums/wsl.txt has another hash, so its shard builds the distribution until the next daily run, or a manual run on main, prepares one. That includes this pull request.
  • Each daily run adds a cache entry of a few GB. Entries that aren't used for 7 days are evicted, so a handful of them are kept at a time. The job could delete the previous ones (with actions: write) if that is too much.
  • The apt packages and the dev container image are as of the day the distribution was prepared.
  • Whether the 1ES pool runs jobs of scheduled and manually started workflows: so far only pull request workflows use it.

How to test

  1. In this pull request, shard 1 finds no cache entry and builds the distribution as before.
  2. After merging, start Code OSS (workspace images) manually on main: the Windows (WSL distribution) job logs the export size and saves the cache. In the next pull requests that don't change the two files, shard 1 restores it, its setup log says imported the prepared distribution, and the WSL suite, the Kerberos proxy run and the cleanup pass.

Validation:

  • cd build && node --test lib/test/detectMissingCaches.test.ts lib/test/detectChanges.test.ts lib/test/workspaceImage.test.ts: 23 passed
  • go run github.com/rhysd/actionlint/cmd/actionlint@latest -shellcheck= .github/workflows/pr-workspace-images.yml .github/workflows/pr-win32-test.yml: only unknown custom runner labels
  • pwsh parse of wslDevContainer.ps1 and of the setup script in pr-win32-test.yml: no errors
  • The saved key starts with the shard's restore key (checked by parsing both workflows)
  • Not run: anything on Windows (Prepare, wsl --import-in-place, the fallback)

Copilot AI balanced review requested due to automatic review settings November 5, 2026 19:02

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.

🔵 Needs a closer look

The new WSL export/import path lacks end-to-end Windows validation, leaving Server 2022 compatibility, complete artifact retrieval, smoke coverage, and failure recovery unverified.

No open issues 🎉

What changed in this PR

This PR reduces repeated WSL provisioning in Windows smoke tests by preparing a reusable distribution alongside the workspace image. The smoke shard imports it when its inputs match, with a fallback to building the distribution from scratch.

Changes:

  • Adds WSL distribution preparation, VHD export/import, and fallback handling.
  • Adds input-validated artifact fetching and integrates it into background smoke-test setup.
  • Updates workflow consistency tests and documentation.

Windows preparation, import, and fallback behavior remain unvalidated on Windows, as noted in the PR.

File Description
test/​smoke/​wslDevContainer.ps1 Adds preparation, export, import, and fallback operations.
test/​smoke/​README.md Documents prepared distributions and fallback behavior.
build/​lib/​test/​workspaceImage.test.ts Checks artifact naming and input-trigger consistency.
.github/​workflows/​workspace_image/​README.md Documents WSL artifact production and consumption.
.github/​workflows/​workspace_image/​image.ts Adds deadline-bound fetching with input validation.
.github/​workflows/​pr.yml Grants Windows jobs artifact-read permission.
.github/​workflows/​pr-workspace-images.yml Prepares, packs, and uploads the WSL distribution.
.github/​workflows/​pr-win32-test.yml Fetches the distribution during background WSL setup.
.github/​skills/​smoke-tests/​SKILL.md Documents prepared WSL distribution handling.

Review effort: Balanced

… shard

The Windows smoke test shard with the WSL suite built its WSL distribution from
scratch in every run: the Ubuntu rootfs, the pinned Linux server, the apt
packages and the dev container image.

wslDevContainer.ps1 gets a Prepare operation that builds the same distribution,
stops Docker Engine, trims it and exports its VHD with
`wsl --export --format vhd`. A new Windows (WSL distribution) job of
pr-workspace-images.yml runs it on the 1ES pool on the daily schedule and on
manual runs, and saves the VHD with actions/cache under a key that hashes
wslDevContainer.ps1 and build/checksums/wsl.txt.

The shard restores the newest entry for its hash, and Setup registers the VHD
under the run's distribution name with `wsl --import-in-place`, starts Docker
Engine and checks the container and bind mount. Without a prepared
distribution, or when importing or starting it fails, Setup builds the
distribution as before. Its outputs, AddServer, Cleanup and the Azure
Pipelines use are unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@lszomoru
Ladislau Szomoru (lszomoru) force-pushed the lszomoru/agents/wsl-prepared-distro branch from 1a7a38c to a7590ca Compare November 5, 2026 19:19
@lszomoru Ladislau Szomoru (lszomoru) changed the title ci: import a WSL distribution prepared with the Windows workspace image ci: import a daily prepared WSL distribution in the Windows WSL smoke shard Nov 5, 2026
@lszomoru
Ladislau Szomoru (lszomoru) marked this pull request as ready for review November 5, 2026 19:24
@lszomoru
Ladislau Szomoru (lszomoru) merged commit c14aa5c into main Nov 5, 2026
59 checks passed
@lszomoru
Ladislau Szomoru (lszomoru) deleted the lszomoru/agents/wsl-prepared-distro branch November 5, 2026 19:33
@vs-code-engineering vs-code-engineering Bot added this to the 1.146.0 milestone Nov 5, 2026
@bryanchen-d

Copy link
Copy Markdown
Collaborator

Ladislau Szomoru (@lszomoru) FYI: since the first daily prepared distribution came in at about 20:40 UTC, Windows / Electron-Smoke (shard 1/3) intermittently fails Agents Window (WSL Dev Container AgentHost) › Starts and reopens a Dev Container session over WSL. So far that's 5 of 26 prepared-distribution runs, against 0 of 30 built-distribution runs earlier today. The devContainer.*.log in the smoke logs artifact shows the cause: the fixture's postCreateCommand gets curl: (6) Could not resolve host: update.code.visualstudio.com, so the session never starts and the test times out waiting for the reply.

I think the problem is Docker's persisted bridge network colliding with WSL's NAT subnet:

  • Prepare stops dockerd but exports /var/lib/docker as is, including the bridge network that dockerd created on the preparing machine (its default 172.17.0.0/16).
  • WSL picks its NAT subnet per host. In both failing runs I checked, the WSL host address is inside 172.17.0.0/16: 172.17.16.1 (the --add-host=vscode-smoke.test:172.17.16.1 in the dev container config) and 172.17.112.1. In the passing runs I checked, the guest is on 172.18, 172.22, 172.26 or 172.31.
  • When dockerd creates the bridge itself, it skips subnets that overlap existing routes, which is why the built path never hit this. The imported distribution reuses the stored 172.17.0.0/16 instead, so from inside the container the resolver and host addresses route into docker0. Image checks and the bind-mount check don't need the network, so they still pass.

Two possible fixes:

  1. In Export-PreparedDistribution, after stopping dockerd, rm -rf /var/lib/docker/network so dockerd chooses a non-overlapping bridge subnet on first start after import.
  2. Pin the bridge to a range WSL doesn't use, through /etc/docker/daemon.json ("bip" or "default-address-pools").

Either option needs a new prepared VHD. I'm happy to send a draft for either one. Which do you prefer?

Co-authored with Copilot

@bryanchen-d

Copy link
Copy Markdown
Collaborator

Ladislau Szomoru (@lszomoru) I've drafted the fix for this as #346615. Before starting dockerd, Start-SmokeDocker now removes /var/lib/docker/network, so dockerd picks a bridge subnet that doesn't overlap WSL's NAT network on each machine, and it logs both subnets. It's still hitting PR CI: the latest was today at 17:51 UTC on #346611. Take it, or close it if you'd rather fix it another way.

Co-authored with Copilot

Bryan Chen (bryanchen-d) added a commit that referenced this pull request Nov 6, 2026
dockerd stores the subnet of its default bridge under /var/lib/docker/network.
The prepared WSL distribution (#346338) brings the subnet chosen on the
machine that prepared it, 172.17.0.0/16, and when WSL puts this machine's NAT
network inside it (172.17.16.0/20, 172.17.112.0/20), containers cannot reach
the resolver: the dev container's postCreateCommand fails with 'Could not
resolve host' and the WSL Dev Container smoke test times out. Remove the
stored network before starting dockerd, so it picks a subnet that does not
overlap this machine's routes, and log both subnets.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Bryan Chen (bryanchen-d) added a commit that referenced this pull request Nov 6, 2026
dockerd stores the subnet of its default bridge under /var/lib/docker/network.
The prepared WSL distribution (#346338) brings the subnet chosen on the
machine that prepared it, 172.17.0.0/16, and when WSL puts this machine's NAT
network inside it (172.17.16.0/20, 172.17.112.0/20), containers cannot reach
the resolver: the dev container's postCreateCommand fails with 'Could not
resolve host' and the WSL Dev Container smoke test times out. Remove the
stored network before starting dockerd, so it picks a subnet that does not
overlap this machine's routes, and log both subnets.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Bryan Chen (bryanchen-d) added a commit that referenced this pull request Nov 6, 2026
…ion (#346615)

dockerd stores the subnet of its default bridge under /var/lib/docker/network.
The prepared WSL distribution (#346338) brings the subnet chosen on the
machine that prepared it, 172.17.0.0/16, and when WSL puts this machine's NAT
network inside it (172.17.16.0/20, 172.17.112.0/20), containers cannot reach
the resolver: the dev container's postCreateCommand fails with 'Could not
resolve host' and the WSL Dev Container smoke test times out. Remove the
stored network before starting dockerd, so it picks a subnet that does not
overlap this machine's routes, and log both subnets.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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