Files
podman/pkg/machine/gvproxy.go
Brent Baude 81003f2d08 Ignore ERROR_SHARING_VIOLATION error on windows
When removing the gvproxy pid file, under CI conditions we could hit a
case where the PID file being removed seemed to have an open handle on
it still.  I could not find anything in podman that left an open handle
and gvproxy would have quit before this, so we think it is likely
another process holding it.  I could not find root cause with CI because
I could not trip the flake.

this new code allows windows (specifically hyperv bc WSL does not use
GVProxy) to ignore an ERROR_SHARING_VIOLATION.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2024-08-06 14:09:36 -05:00

32 lines
760 B
Go

package machine
import (
"errors"
"fmt"
"io/fs"
"strconv"
"github.com/containers/podman/v5/pkg/machine/define"
)
// CleanupGVProxy reads the --pid-file for gvproxy attempts to stop it
func CleanupGVProxy(f define.VMFile) error {
gvPid, err := f.Read()
if err != nil {
// The file will also be removed by gvproxy when it exits so
// we need to account for the race and can just ignore it here.
if errors.Is(err, fs.ErrNotExist) {
return nil
}
return fmt.Errorf("unable to read gvproxy pid file: %v", err)
}
proxyPid, err := strconv.Atoi(string(gvPid))
if err != nil {
return fmt.Errorf("unable to convert pid to integer: %v", err)
}
if err := waitOnProcess(proxyPid); err != nil {
return err
}
return removeGVProxyPIDFile(f)
}