Skip to content

ci: stop WSL before exporting the prepared WSL distribution - #346355

Merged
Ladislau Szomoru (lszomoru) merged 2 commits into
mainfrom
lszomoru/agents/wsl-distro-export-shutdown
Nov 5, 2026
Merged

Ladislau Szomoru (lszomoru) merged 2 commits into
mainfrom
lszomoru/agents/wsl-distro-export-shutdown

Conversation

@lszomoru

Copy link
Copy Markdown
Member

Follow-up to #346338. The first run of its wsl-distro job (run 42096277037) prepared the distribution, then failed to export it:

Exporting vscode-wsl-smoke-… failed (exit code -1): The process cannot access the file because it is being used by another process.
Error code: Wsl/Service/ERROR_SHARING_VIOLATION

Export-PreparedDistribution in test/smoke/wslDevContainer.ps1 stopped the distribution with wsl --terminate before wsl --export --format vhd, but the utility VM keeps holding the VHD of the distribution after --terminate; only wsl --shutdown reliably releases it (microsoft/WSL#10737, microsoft/WSL#12434). The Prepare operation runs in a job of its own on a dedicated machine, so it now stops the VM with wsl --shutdown before the export. The only step after the export, which unregisters the distribution, doesn't need a running VM.

Also renames the job to Windows (WSL distro).

Until a run exports the distribution, the WSL smoke shard finds no prepared distribution and builds it as before.

How to test

The wsl-distro job only runs on schedule and manual dispatch, so the checks of this pull request don't run it. Dispatch pr-workspace-images.yml on this branch (gh workflow run pr-workspace-images.yml --ref lszomoru/agents/wsl-distro-export-shutdown) and check that Windows (WSL distro) exports and saves the distribution. After merging, dispatch it on main once: the cache key hashes wslDevContainer.ps1, so the WSL smoke shard only finds a distribution exported by a run with this change.

Validation:

  • pwsh [System.Management.Automation.Language.Parser]::ParseFile on test/smoke/wslDevContainer.ps1: no errors
  • go run github.com/rhysd/actionlint/cmd/actionlint@latest -shellcheck= .github/workflows/pr-workspace-images.yml: only unknown custom runner labels
  • cd build && node --test lib/test/detectMissingCaches.test.ts lib/test/detectChanges.test.ts: 22 passed

The first run of the wsl-distro job of pr-workspace-images.yml failed
to export the distribution: `wsl --export --format vhd` reports a
sharing violation while the utility VM still holds the VHD of the
distribution, which `wsl --terminate` doesn't release
(microsoft/WSL#10737). Prepare runs in a job
of its own, so it now stops the VM with `wsl --shutdown` before the
export.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 5, 2026 19:52
@lszomoru
Ladislau Szomoru (lszomoru) marked this pull request as ready for review November 5, 2026 19:53

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

PR checks do not exercise Prepare, so a manually dispatched wsl-distro job must confirm that Windows/WSL releases the VHD on the 1ES runner and that export and caching succeed.

No open issues 🎉

What changed in this PR

This follow-up to #346338 addresses the sharing violation when exporting the prepared WSL distribution used by Windows smoke tests.

Changes:

  • Replace distribution-only termination with wsl --shutdown to release the VHD before export, with updated error handling and an explanatory comment.
  • Rename the preparation job to Windows (WSL distro).

No actionable findings remain. End-to-end export validation still requires a manual workflow run because pull request checks do not run this job.

File Description
test/​smoke/​wslDevContainer.ps1 Shut down WSL before exporting the prepared distribution’s VHD.
.github/​workflows/​pr-workspace-images.yml Rename the WSL preparation job’s display label.

Review effort: Balanced

@lszomoru
Ladislau Szomoru (lszomoru) merged commit 6a6974d into main Nov 5, 2026
60 checks passed
@lszomoru
Ladislau Szomoru (lszomoru) deleted the lszomoru/agents/wsl-distro-export-shutdown branch November 5, 2026 20:06
@vs-code-engineering vs-code-engineering Bot added this to the 1.146.0 milestone Nov 5, 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