Skip to content

Commit d77658e

Browse files
committed
cirrus: setup WSL logging
To debug some of the WSL issues we are seeing try to setup logging, the script parts are taken from the offical logging script[1] but modified to use a predictable dir/filename we can upload in cirrus and I also removed the interactive prompts. [1] https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1 Signed-off-by: Paul Holzinger <[email protected]>
1 parent f691fa7 commit d77658e

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

.cirrus.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,8 +847,95 @@ podman_machine_windows_task:
847847
$Partition | Add-PartitionAccessPath -AccessPath "Z:\"
848848
echo "Get-Volume"
849849
Get-Volume
850+
wsl_log_setup_script: |
851+
[CmdletBinding()]
852+
Param (
853+
$LogProfile = $null,
854+
[switch]$Dump = $false
855+
)
856+
857+
Set-StrictMode -Version Latest
858+
859+
$folder = "logs"
860+
mkdir -p $folder | Out-Null
861+
862+
if ($LogProfile -eq $null -Or ![System.IO.File]::Exists($LogProfile))
863+
{
864+
if ($LogProfile -eq $null)
865+
{
866+
$url = "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl.wprp"
867+
}
868+
elseif ($LogProfile -eq "storage")
869+
{
870+
$url = "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl_storage.wprp"
871+
}
872+
else
873+
{
874+
Write-Error "Unknown log profile: $LogProfile"
875+
exit 1
876+
}
877+
878+
$LogProfile = "$folder/wsl.wprp"
879+
try {
880+
Invoke-WebRequest -UseBasicParsing $url -OutFile $LogProfile
881+
}
882+
catch {
883+
throw
884+
}
885+
}
886+
887+
reg.exe export HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss $folder/HKCU.txt 2>&1 | Out-Null
888+
reg.exe export HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Lxss $folder/HKLM.txt 2>&1 | Out-Null
889+
reg.exe export HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\P9NP $folder/P9NP.txt 2>&1 | Out-Null
890+
reg.exe export HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2 $folder/Winsock2.txt 2>&1 | Out-Null
891+
reg.exe export "HKEY_CLASSES_ROOT\CLSID\{e66b0f30-e7b4-4f8c-acfd-d100c46c6278}" $folder/wslsupport-proxy.txt 2>&1 | Out-Null
892+
reg.exe export "HKEY_CLASSES_ROOT\CLSID\{a9b7a1b9-0671-405c-95f1-e0612cb4ce7e}" $folder/wslsupport-impl.txt 2>&1 | Out-Null
893+
Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" > $folder/windows-version.txt
894+
895+
Get-Service wslservice -ErrorAction Ignore | Format-list * -Force > $folder/wslservice.txt
896+
897+
$wslconfig = "$env:USERPROFILE/.wslconfig"
898+
if (Test-Path $wslconfig)
899+
{
900+
Copy-Item $wslconfig $folder | Out-Null
901+
}
902+
903+
get-appxpackage MicrosoftCorporationII.WindowsSubsystemforLinux -ErrorAction Ignore > $folder/appxpackage.txt
904+
get-acl "C:\ProgramData\Microsoft\Windows\WindowsApps" -ErrorAction Ignore | Format-List > $folder/acl.txt
905+
Get-WindowsOptionalFeature -Online > $folder/optional-components.txt
906+
bcdedit.exe > $folder/bcdedit.txt
907+
908+
$uninstallLogs = "$env:TEMP/wsl-uninstall-logs.txt"
909+
if (Test-Path $uninstallLogs)
910+
{
911+
Copy-Item $uninstallLogs $folder | Out-Null
912+
}
913+
914+
$wprOutputLog = "$folder/wpr.txt"
915+
916+
wpr.exe -start $LogProfile -filemode 2>&1 >> $wprOutputLog
917+
if ($LastExitCode -Ne 0)
918+
{
919+
Write-Host -ForegroundColor Yellow "Log collection failed to start (exit code: $LastExitCode), trying to reset it."
920+
wpr.exe -cancel 2>&1 >> $wprOutputLog
921+
922+
wpr.exe -start $LogProfile -filemode 2>&1 >> $wprOutputLog
923+
if ($LastExitCode -Ne 0)
924+
{
925+
Write-Host -ForegroundColor Red "Couldn't start log collection (exitCode: $LastExitCode)"
926+
}
927+
}
850928
main_script: ".\\repo\\contrib\\cirrus\\win-podman-machine-main.ps1"
851929
always:
930+
wsl_log_done_script: |
931+
$folder = "logs"
932+
wpr.exe -stop $folder/logs.etl 2>&1 >> $wprOutputLog
933+
$logArchive = "$(Resolve-Path $folder).zip"
934+
Compress-Archive -Path $folder -DestinationPath $logArchive
935+
Remove-Item $folder -Recurse
936+
937+
wsl_artifacts:
938+
path: ./logs.zip
852939
# Required for `contrib/cirrus/logformatter` to work properly
853940
html_artifacts:
854941
path: ./*.html

0 commit comments

Comments
 (0)