Skip to content

ci: install current WSL on Windows smoke agents to fix flaky WSL setup - #342344

Merged
Alexandru Dima (alexdima) merged 7 commits into
mainfrom
agents/fix-flaky-wsl-dev-container-ci-step
Oct 18, 2026
Merged

Alexandru Dima (alexdima) merged 7 commits into
mainfrom
agents/fix-flaky-wsl-dev-container-ci-step

Conversation

@alexdima

@alexdima Alexandru Dima (alexdima) commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

The Prepare WSL Dev Container smoke tests step in the Windows Electron smoke jobs was the top Windows flake last week. This PR fixes its cause: the Windows CI agents run an old inbox WSL with a 2021 WSL2 kernel. The PR installs a current, pinned WSL release instead, and puts a time limit on every wsl.exe call. A failed WSL setup still fails the job, as before. The same shared installer is also what the sanity tests need to run WSL tests again (#342405, stacked on #342227).

Root cause

The 1ES windows-2022 images only have the inbox WSL. The setup diagnostics on a failed run show it:

wsl.exe file version: 10.0.20348.2849
wsl --version: Invalid command line option: --version
Default Version: 1
Kernel version: 5.10.16

They have no WSL2 kernel. wslDevContainer.ps1 installed the standalone wsl_update_x64.msi, which provides kernel 5.10.16.3, built in April 2021. With it, the WSL2 utility VM sometimes:

Earlier PRs fixed one symptom each: #337229 (download retries), #337644 (kernel installer cache), #338047 (import retries). The 325 MB rootfs download was never the problem: it finished in 3–4 s in every failed run. The "28 kB/s" figure people noticed was curl's first progress line.

The sanity tests have the same root cause (#342227). They never install a WSL2 kernel at all, so wsl --import Ubuntu fails with "WSL 2 requires an update to its kernel component", and every wsl-* sanity test has been skipped since late May.

Failure counts (Oct 10–17)

There were 16 confirmed flakes: an attempt failed in this step, then a re-run of the same SHA passed. Four more failures had the same signatures but were never re-run.

Signature Count
wsl --import hangs until the step timeout. The rootfs had already downloaded in 3–4 s at 80–103 MB/s. 9
A process crashes right after the distro's first boot: apt-get SIGSEGV (5), apt-get std::logic_error abort (1), containerd SIGSEGV ×2 (1) 7

Azure DevOps had one more: build 485030 shows the same import hang.

Baseline rate: in the latest 500 pr.yml runs before this PR, 6 of 499 WSL setups failed (1.2%). #338047 measured about 4% in September.

Failed attempts
Date (UTC) Failed job Failure
2026-10-16 Windows (shard 1/2) / Electron-Smoke wsl --import hung after rootfs download finished in 3–4s; step timed out at 15 min; cleanup then also timed out at 5 min
2026-10-16 Windows / Electron-Smoke wsl --import hung after rootfs download finished in 3–4s; step timed out at 15 min; cleanup then also timed out at 5 min
2026-10-16 Windows / Electron-Smoke wsl --import hung after rootfs download finished in 3–4s; step timed out at 15 min; cleanup then also timed out at 5 min
2026-10-16 Windows / Electron-Smoke wsl --import hung after rootfs download finished in 3–4s; step timed out at 15 min; cleanup then also timed out at 5 min
2026-10-16 Windows / Electron-Smoke wsl --import hung after rootfs download finished in 3–4s; step timed out at 15 min; cleanup then also timed out at 5 min
2026-10-16 Windows / Electron-Smoke wsl --import hung after rootfs download finished in 3–4s; step timed out at 15 min; cleanup then also timed out at 5 min
2026-10-16 Windows / Electron-Smoke wsl --import hung after rootfs download finished in 3–4s; step timed out at 15 min; cleanup then also timed out at 5 min
2026-10-16 Windows / Electron-Smoke wsl --import hung after rootfs download finished in 3–4s; step timed out at 15 min; cleanup then also timed out at 5 min
2026-10-16 Windows / Electron-Smoke wsl --import hung after rootfs download finished in 3–4s; step timed out at 15 min; cleanup then also timed out at 5 min
2026-10-17 Windows (shard 1/2) / Electron-Smoke containerd SIGSEGV (×2) → dockerd failed to start
2026-10-16 Windows (shard 1/2) / Electron-Smoke apt-get install SIGSEGV (exit 139)
2026-10-16 Windows / Electron-Smoke apt-get install SIGSEGV (exit 139)
2026-10-16 Windows / Electron-Smoke apt-get install SIGSEGV (exit 139)
2026-10-16 Windows / Electron-Smoke import exit -1 (retried OK), then apt-get install SIGSEGV (exit 139)
2026-10-12 Windows / Electron-Smoke apt-get install abort: std::logic_error (exit 134)
2026-10-14 Windows / Electron-Smoke apt-get install SIGSEGV (exit 139)

Changes

1. Install a current, pinned WSL

  • New shared module build/azure-pipelines/common/wsl.psm1 installs the release pinned in build/checksums/wsl.txt: WSL 3.0.3, wsl.3.0.3.0.x64.msi from microsoft/WSL.
  • It checks the SHA256, which matches the asset digest on the release page, and the Microsoft Authenticode signature.
  • It installs with msiexec /qn /norestart, waits until wsl --status no longer reports "finishing an upgrade", and checks that the new version is active before setting WSL2 as the default.
  • It logs the host OS build and CPU model, which nothing recorded before.
  • It does nothing when that release or a newer one is already installed, so it keeps working once the image ships current WSL.

2. Time limits on all wsl.exe calls

  • Invoke-WslExe kills wsl.exe after a timeout. A hung import now takes 2 minutes, then gets diagnostics, wsl --shutdown --force, and a retry on a fresh utility VM. Before, it ran into the 15-minute step timeout.
  • Diagnostics and cleanup can no longer hang either. Cleanup leaves the files in place when WSL doesn't respond.

3. Caching

  • The old date-keyed kernel cache and its background refresh are replaced by a cache keyed on build/checksums/wsl.txt.
  • GitHub: a new composite action restore-wsl-installer restores it. pr-node-modules.yml fills the cache on main, the same way it handles Electron, so PRs only read it.
  • Azure DevOps: Cache@2 with the same key.
  • Downloads now retry on all errors (--retry-all-errors).

4. No skipping. A failed WSL setup still fails the job. An earlier revision of this PR let PR CI skip the WSL suite when setup failed. That hid real regressions in the setup or the WSL path behind a green job, so it was removed. The prepare step keeps its 15-minute timeout: in the worst case, the bounded import retries need about 14 minutes.

Updating WSL: replace the line in build/checksums/wsl.txt. This is documented in the smoke-tests skill.

Validation

What Result
Probe: 5 rounds × 20 parallel jobs on 1es-vscode-oss-windows-2022-x64, each running the full prepare + cleanup (run 39137587992, 4 attempts; run 39143082726). The temporary workflow is removed again. 100 of 100 succeeded. Prepare took 92–127 s and cleanup 2–3 s. The MSI installed in 13–23 s, with no reboot needed (exit 0). Every job ran WSL 3.0.3.0 with kernel 6.18.54.1. The hosts are Xeon Platinum 8573C and 8370C.
PR CI, Windows (shard 1/2) / Electron-Smoke, job 117705160723 (8573C) and job 117721316396 (8370C) ✅ WSL suite ran and passed: Starts and reopens a Dev Container session over WSL (77.7 s, 71.6 s)
Azure DevOps 1es-windows-2022-x64 pool, through the sanity runs in #342405 (485751, 485752, 485757, 485758, 485759) ✅ Install-Wsl installed 3.0.3 in about 20 s on each; Ubuntu imported as WSL2
Azure DevOps product build (CI type, Windows only, no publishing) 485777 on 1es-windows-2022-x64 ✅ Prepare WSL Dev Container smoke tests -CI AzureDevOps took 2m20s (WSL 3.0.3, kernel 6.18). The required WSL suite passed (Starts and reopens a Dev Container session over WSL, 63.8 s), 91 passing. Cleanup took 4 s, and Cache@2 saved the 367.6 MB installer. Its only failure was the build-script test below, now fixed.
build/lib/test/testCheckpointTemplates.test.ts (node --test), which asserts the ADO WSL step names ✅ 14/14 after updating the expected steps; agentHostTestSelection.test.ts 8/8
PR CI on the final head (a222bd3), run 39147910162 ✅ all checks green, including Compile & Hygiene
Independent static review of the PowerShell and YAML No issues found

About the numbers: at the 1.2% baseline, 100 VMs would show about 1.2 failures on average, and 0 failures would still happen by chance about 30% of the time. So the probe shows the new setup works across many agents. On its own it doesn't prove a lower failure rate. The stronger argument is replacing a 2021 kernel with the supported current WSL, plus hangs now becoming 2-minute retries. The rate is worth tracking after merge with the CPU: and WSL version: log lines.

Not validated:

  • The GitHub cache fill in pr-node-modules.yml, which only runs on main. Until then, PR runs download the 368 MB MSI from GitHub releases, which took a few seconds in the probe.
  • PowerShell couldn't be run locally. CI is its only execution.

The Windows PR smoke step that provisions WSL flaked 16 times between Oct 10 and 17. Every flake happened inside the runner's WSL2 VM, never in a download: either wsl --import hung until the step timed out (9), or apt-get/containerd crashed right after the first boot (7). A re-run on a new VM passes.

Provisioning only sets up test infrastructure, so in PR CI a failure no longer fails the job. The WSL suite skips itself at runtime, so the shard split doesn't change. Lower the setup timeout from 15 to 10 minutes, since a healthy setup takes under 2. The Azure DevOps product build still requires the suite.

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 17, 2026 23:10

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.

🟢 Approval recommended

The narrow fallback preserves shard registration and strict checks outside the explicitly tolerated provisioning-failure path.

No open issues 🎉

What changed in this PR

Makes WSL provisioning failures non-blocking in Windows PR smoke tests while preserving strict Azure DevOps coverage.

Changes:

  • Tolerates provisioning failures and shortens the setup timeout.
  • Skips the affected suite at runtime without changing shard assignments.
  • Documents the fallback behavior.

The tolerated-failure path has not yet been exercised in real CI.

File Description
test/​smoke/​src/​areas/​agentsWindow/​agentsWindow.test.ts Skips required WSL tests when provisioning explicitly fails.
.github/​workflows/​pr-win32-test.yml Passes setup outcome, tolerates failures, and adjusts timeout and cleanup handling.
.github/​skills/​smoke-tests/​SKILL.md Documents runtime skipping and unchanged product-build requirements.

Review effort: Balanced

The Windows Server 2022 agents only have the inbox WSL (wsl.exe 10.0.20348). With the 2021 standalone WSL2 kernel (5.10.16), its utility VM intermittently hangs on import, shuts down right after boot, or crashes processes such as apt-get and containerd. Earlier fixes (#337229, #337644, #338047) worked around single symptoms.

- Install the WSL release pinned in build/checksums/wsl.txt (3.0.3) from build/azure-pipelines/common/wsl.psm1, verifying its SHA256 and Microsoft signature, and log the host CPU and WSL versions.
- Cache the installer by that pin: actions/cache, filled on main by pr-node-modules.yml, and Cache@2 in the product build. This replaces the daily kernel installer cache.
- Run every wsl.exe call with a timeout, so a hung import is retried on a fresh utility VM and diagnostics and cleanup can't hang.
- Retry downloads on all errors.

Co-authored-by: Copilot <[email protected]>
100 of 100 probe VMs provisioned WSL successfully in 92-124 seconds.

Co-authored-by: Copilot <[email protected]>
@alexdima Alexandru Dima (alexdima) changed the title ci: tolerate WSL Dev Container provisioning failures in Windows PR smoke tests ci: install current WSL on Windows smoke agents to fix flaky WSL setup Oct 18, 2026
…te test

The kernel cache day and kernel installer cache steps were replaced by a single version-keyed WSL installer cache.

Co-authored-by: Copilot <[email protected]>
Skipping the WSL Dev Container suite after a failed setup hid real regressions in the setup or the WSL path behind a green job. It was a stopgap while setup flaked on the inbox WSL; with current WSL installed, a failed setup should fail the PR. Restore the 15-minute step timeout so the bounded import retries have room.

Co-authored-by: Copilot <[email protected]>

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

Windows timeout recovery and the unvalidated main-branch cache-fill path warrant final maintainer review.

No open issues 🎉

Review effort: Balanced

@alexdima
Alexandru Dima (alexdima) merged commit 966268a into main Oct 18, 2026
50 checks passed
@alexdima
Alexandru Dima (alexdima) deleted the agents/fix-flaky-wsl-dev-container-ci-step branch October 18, 2026 20:10
@vs-code-engineering vs-code-engineering Bot added this to the 1.143.0 milestone Oct 18, 2026
Bryan Chen (bryanchen-d) added a commit that referenced this pull request Oct 22, 2026
None of the 17 Cache@2 steps in the product build retried, so one transient
pipeline-cache error failed the whole job even though every restore has a
miss fallback. Over 90 days of main and release builds:

- 8 builds failed on `Too Many Requests` (429) from the cache service,
  2 of them in the post-job save
- 487166 (official insider) lost Windows ARM64 Compile when the built-in
  extensions restore timed out after ~15 min of blob retries
- 11 builds hit connection refused in a WSL cache restore that has since
  been removed (#342344)

Add `retryCountOnTaskFailure: 2` to every Cache@2 step. A failure that
survives both retries still fails the job: Cache@2 has no fail-open input,
and `continueOnError` would turn the build partial.

Co-authored-by: Copilot <[email protected]>
Bryan Chen (bryanchen-d) added a commit that referenced this pull request Oct 22, 2026
None of the 17 Cache@2 steps in the product build retried, so one transient
pipeline-cache error failed the whole job even though every restore has a
miss fallback. Over 90 days of main and release builds:

- 8 builds failed on `Too Many Requests` (429) from the cache service,
  2 of them in the post-job save
- 487166 (official insider) lost Windows ARM64 Compile when the built-in
  extensions restore timed out after ~15 min of blob retries
- 11 builds hit connection refused in a WSL cache restore that has since
  been removed (#342344)

Add `retryCountOnTaskFailure: 2` to every Cache@2 step. A failure that
survives both retries still fails the job: Cache@2 has no fail-open input,
and `continueOnError` would turn the build partial.

Co-authored-by: Copilot <[email protected]>
Bryan Chen (bryanchen-d) added a commit that referenced this pull request Oct 22, 2026
None of the 17 Cache@2 steps in the product build retried, so one transient
pipeline-cache error failed the whole job even though every restore has a
miss fallback. Over 90 days of main and release builds:

- 8 builds failed on `Too Many Requests` (429) from the cache service,
  2 of them in the post-job save
- 487166 (official insider) lost Windows ARM64 Compile when the built-in
  extensions restore timed out after ~15 min of blob retries
- 11 builds hit connection refused in a WSL cache restore that has since
  been removed (#342344)

Add `retryCountOnTaskFailure: 2` to every Cache@2 step. A failure that
survives both retries still fails the job: Cache@2 has no fail-open input,
and `continueOnError` would turn the build partial.

Co-authored-by: Copilot <[email protected]>
Ladislau Szomoru (lszomoru) added a commit that referenced this pull request Oct 23, 2026
All 18 WSL Dev Container prep failures since #342344 were apt-get inside
the WSL distro stalling on archive.ubuntu.com and security.ubuntu.com,
which ran past the 300 second command timeout. apt now uses the Azure
Ubuntu mirror, as build-snap.sh and the sanity tests already do, and
retries failed downloads.

The rootfs and server downloads now abort transfers that are too slow to
finish, since a transfer that ran into --max-time was already past
--retry-max-time and was never retried.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ladislau Szomoru (lszomoru) added a commit that referenced this pull request Oct 28, 2026
* test: use the Azure Ubuntu mirror in the WSL smoke setup

All 18 WSL Dev Container prep failures since #342344 were apt-get inside
the WSL distro stalling on archive.ubuntu.com and security.ubuntu.com,
which ran past the 300 second command timeout. apt now uses the Azure
Ubuntu mirror, as build-snap.sh and the sanity tests already do, and
retries failed downloads.

The rootfs and server downloads now abort transfers that are too slow to
finish, since a transfer that ran into --max-time was already past
--retry-max-time and was never retried.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test: retry WSL smoke downloads that run into --max-time

curl only retries while --retry-max-time hasn't passed. It was 120
seconds, shorter than --max-time (180 seconds), so a download that was
fast enough to pass the 1 MiB/s speed limit but too slow to finish in
time (about 1.2-1.8 MiB/s for the 210-325 MiB downloads) ran until
--max-time and was never retried. The retry window is now 300 seconds,
so such a transfer is retried too.

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Copilot <[email protected]>
Martin Aeschlimann (aeschli) added a commit that referenced this pull request Nov 2, 2026
#342405)

<!-- Thank you for submitting a Pull Request. Please:
* Read our Pull Request guidelines:

https://github.com/microsoft/vscode/wiki/How-to-Contribute#pull-requests
* Associate an issue with the Pull Request.
* Ensure that the code is up-to-date with the `main` branch.
* Include a description of the proposed changes and how to test them.
-->

Restores the Windows x64 WSL sanity tests by installing the pinned
current WSL release, including its WSL2 kernel, and fixing desktop
launch and connection readiness. This makes the WSL coverage in #342227
usable again, including its regression check for #341396.

## Scope and Related PRs

- #342616 is merged into `main` and supplies WSL command timeouts,
exit-code normalization, and missing-coverage warnings. This branch
merges current `main`; it no longer changes `context.ts` or `runWsl.ts`.
- #342227 exclusively owns the Markdown-preview/webview-resource check.
That code and its documentation have been removed from this PR;
`uiTest.ts` now matches `main` exactly.
- #342344 already supplies the shared WSL installer and checksum pin.
This PR consumes that installer rather than duplicating it.

The remaining diff is four files: the sanity pipeline template, the
Windows setup script, the WSL tests, and directly related README
updates.

## Remaining Changes

- Install the WSL release pinned in `build/checksums/wsl.txt` on Windows
x64 before importing Ubuntu. ARM64 installation behavior is unchanged.
- Cache the installer and include `build/checksums` in the pipeline's
sparse checkout.
- Set `WSL_UTF8=1` so redirected distribution names can be read
correctly.
- Convert Ubuntu to WSL2 only when needed, using the shared bounded
`Invoke-WslExe` helper for the new version probe. A timeout or nonzero
exit code is not treated as a successful probe.
- Fail and retry HTTP errors while downloading the Ubuntu rootfs.
- Pass `--folder-uri` last when launching the WSL desktop test, avoiding
Electron's refusal to accept arguments following a URL-like argument.
- Wait for the connected `WSL: ...` remote indicator rather than any
text containing `WSL`.
- Wait for WSL2 localhost forwarding through the existing retrying
`/version` fetch before navigating the server-web test.

## Validation

### Current Head

Merged `origin/main` at `72a22c9d71f` into the PR branch. The validated
PR head is `084ebfde057f18ec2436a984f75f60b48989d1e2`; the diff remains
limited to the four files described above.

- `pnpm --dir test/sanity exec tsc --noEmit`: passed.
- `pnpm run eslint test/sanity/src/wsl.test.ts`: passed.
- `git diff --cached --check`: passed.
- `git diff --check`: passed.
- `git commit`: passed, including the required pre-commit hygiene hook.

[Product build
491899](https://dev.azure.com/monacotools/Monaco/_build/results?buildId=491899)
built and tested that exact PR head. **All nine Windows x64 sanity tests
passed**, including `wsl-server-x64`, `wsl-server-web-x64`, and
`wsl-desktop-x64`. Each WSL test executed once, without a test retry.
The log confirms WSL `3.0.3.0`, Ubuntu running as WSL2, the connected
`WSL: Ubuntu` indicator, and Markdown-preview coverage.

The overall build is **partially successful**, not fully green: native
Linux sanity attempted `desktop-linux-snap-x64` and received a 404
because this validation configuration disabled the Snap build. Windows
x64 sanity, Windows/Linux build stages, Web, and Publish passed.
Artifact publishing was enabled with approval; `VSCODE_RELEASE=false`
and no release stage ran.

### Historical Windows Evidence

Before removing the overlap, [Product Sanity Tests run
485962](https://dev.azure.com/monacotools/Monaco/_build/results?buildId=485962),
against Insiders `341e0fa9`, passed all nine Windows x64 tests.
`wsl-server-x64`, `wsl-server-web-x64`, and `wsl-desktop-x64` all passed
on their first attempt.

The combined WSL2 provisioning and Markdown-preview check also caught
#341396: [run
485823](https://dev.azure.com/monacotools/Monaco/_build/results?buildId=485823)
failed on buggy `c03d2e4a` with webview resource 401s, while [run
485824](https://dev.azure.com/monacotools/Monaco/_build/results?buildId=485824)
passed on fixed `16d22415`. The preview assertion now belongs only to
#342227; these are historical results, not a rerun of the simplified
head.
Wing K.Y (wingwkyuen) pushed a commit to tcgoidc/vscode that referenced this pull request Nov 2, 2026
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