From 7ad8f0c879beff7df6cb80ff1a2bcbcbf3509a8d Mon Sep 17 00:00:00 2001 From: Mario Loriedo Date: Mon, 6 Oct 2025 15:23:42 +0200 Subject: [PATCH] WSL machine tests: increase kernel boot timeout This is to avoid CI/CD flakes and is based on this analysis of the WSL flakes logs: https://github.com/microsoft/WSL/issues/13301#issuecomment-3367452109 Signed-off-by: Mario Loriedo --- contrib/cirrus/win-podman-machine-test.ps1 | 18 ++++++++++++++++++ pkg/machine/e2e/machine_test.go | 15 +++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/contrib/cirrus/win-podman-machine-test.ps1 b/contrib/cirrus/win-podman-machine-test.ps1 index 72a9949d67..bb1701595d 100644 --- a/contrib/cirrus/win-podman-machine-test.ps1 +++ b/contrib/cirrus/win-podman-machine-test.ps1 @@ -43,7 +43,25 @@ $Env:TEMP = 'Z:\' Write-Host "`nRunning podman-machine e2e tests" if ($Env:TEST_FLAVOR -eq "machine-wsl") { + if ($Env:CIRRUS_CI -eq "true") { + # Add a WSL configuration file + # The `kernelBootTimeout` configuration is to prevent CI/CD flakes + # See + # https://github.com/microsoft/WSL/issues/13301#issuecomment-3367452109 + Write-Host "`nAdding WSL configuration file" + $wslConfigPath = "$env:UserProfile\.wslconfig" + $wslConfigContent = @" +[wsl2] +kernelBootTimeout=300000 # 5 minutes +"@ + Set-Content -Path $wslConfigPath -Value $wslConfigContent -Encoding utf8 + wsl --shutdown + Write-Host "`n$wslConfigPath content:" + Get-Content -Path $wslConfigPath + } + # Output info so we know what version we are testing. + Write-Host "`nOutputting WSL version:" wsl --version Run-Command "$PSScriptRoot\win-collect-wsl-logs-start.ps1" } diff --git a/pkg/machine/e2e/machine_test.go b/pkg/machine/e2e/machine_test.go index 0dfb0274c9..eac2b9f25f 100644 --- a/pkg/machine/e2e/machine_test.go +++ b/pkg/machine/e2e/machine_test.go @@ -144,6 +144,21 @@ func setup() (string, *machineTestBuilder) { if err := os.Setenv("USERPROFILE", homeDir); err != nil { Fail("unable to set home dir on windows") } + if testProvider.VMType() == define.WSLVirt { + // create file $USERPROFILE/.wslconfig + // https://github.com/microsoft/WSL/issues/13301#issuecomment-3367452109 + wslconfig, err := os.Create(filepath.Join(homeDir, ".wslconfig")) + if err != nil { + Fail(fmt.Sprintf("failed to create wslconfig file: %q", err)) + } + _, err = wslconfig.WriteString("[wsl]\nkernelBootTimeout=300000") + if err != nil { + Fail(fmt.Sprintf("failed to write wslconfig file: %q", err)) + } + if err := wslconfig.Close(); err != nil { + Fail(fmt.Sprintf("failed to close wslconfig file: %q", err)) + } + } } if err := os.Setenv("XDG_RUNTIME_DIR", homeDir); err != nil { Fail("failed to set xdg_runtime dir")