diff --git a/.github/workflows/pr-workspace-images.yml b/.github/workflows/pr-workspace-images.yml index 4874a5626be69c..e4a917ca625d7a 100644 --- a/.github/workflows/pr-workspace-images.yml +++ b/.github/workflows/pr-workspace-images.yml @@ -394,7 +394,7 @@ jobs: # job. The cache key hashes the files that define the distribution, so that the shard of a commit that changes them # builds the distribution instead; the shard restores the newest entry of its key. wsl-distro: - name: Windows (WSL distribution) + name: Windows (WSL distro) if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} runs-on: [ self-hosted, 1ES.Pool=1es-vscode-oss-windows-2022-x64, "JobId=wsl-distro-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}" ] timeout-minutes: 30 diff --git a/test/smoke/wslDevContainer.ps1 b/test/smoke/wslDevContainer.ps1 index 98c5c0f437a71f..a7b58d280c500b 100644 --- a/test/smoke/wslDevContainer.ps1 +++ b/test/smoke/wslDevContainer.ps1 @@ -426,9 +426,12 @@ rm -rf /var/lib/apt/lists/* sync fstrim --verbose / || echo 'fstrim failed, so the export keeps the blocks of deleted files.' '@ - $terminate = Invoke-WslExe -ArgumentList '--terminate', $Distribution -TimeoutSeconds 60 - if ($terminate.ExitCode -ne 0) { - throw "Failed to stop $Distribution before exporting it ($(Format-WslResult $terminate))." + # A VHD export fails with a sharing violation while the utility VM still holds the distribution's VHD, which + # --terminate doesn't release (https://github.com/microsoft/WSL/issues/10737). Prepare runs in a job of its own, so + # it stops the VM. + $shutdown = Invoke-WslExe -ArgumentList '--shutdown' -TimeoutSeconds 60 + if ($shutdown.ExitCode -ne 0) { + throw "Failed to stop WSL before exporting $Distribution ($(Format-WslResult $shutdown))." } New-Item -ItemType Directory -Force -Path (Split-Path $Path -Parent) | Out-Null Remove-Item -LiteralPath $Path -ErrorAction SilentlyContinue