From e059055aa5de00c9d27589082fd68753382005e4 Mon Sep 17 00:00:00 2001 From: Brent Baude Date: Fri, 7 Nov 2025 10:41:32 -0600 Subject: [PATCH] Fix WSL machine start with --update-connection In my previous PR, #27405, the optional WSL tests do not pass because of an early return consistent with WSL's networking. This PR corrects the problem. Fixes: #27469 Signed-off-by: Brent Baude --- pkg/machine/shim/host.go | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/pkg/machine/shim/host.go b/pkg/machine/shim/host.go index e1fec6d664..feef52b96f 100644 --- a/pkg/machine/shim/host.go +++ b/pkg/machine/shim/host.go @@ -664,9 +664,21 @@ func Start(mc *vmconfigs.MachineConfig, mp vmconfigs.VMProvider, opts machine.St } } + // embedded function for handling if we should update the default connection + // and the actual update + updateConnectionFunc := func() error { + if !updateDefaultConnection { + return nil + } + return config.EditConnectionConfig(func(cfg *config.ConnectionsFile) error { + logrus.Infof("Setting default Podman connection to %s", connName) + cfg.Connection.Default = connName + return nil + }) + } // Provider is responsible for waiting if mp.UseProviderNetworkSetup() { - return nil + return updateConnectionFunc() } noInfo := opts.NoInfo @@ -679,17 +691,7 @@ func Start(mc *vmconfigs.MachineConfig, mp vmconfigs.VMProvider, opts machine.St noInfo, mc.HostUser.Rootful, ) - - // return if we dont need to set the machine to the default connection - // or it was determined to already be the default earlier - if !updateDefaultConnection { - return nil - } - return config.EditConnectionConfig(func(cfg *config.ConnectionsFile) error { - logrus.Infof("Setting default Podman connection to %s", connName) - cfg.Connection.Default = connName - return nil - }) + return updateConnectionFunc() } func Set(mc *vmconfigs.MachineConfig, mp vmconfigs.VMProvider, opts machineDefine.SetOptions) error {