Skip to content

Commit b338364

Browse files
Merge pull request #21786 from Luap99/machine-gvproxy-cleanup
pkg/machine: ignore gvproxy pidfile not exists error
2 parents 5a84451 + 6f6925c commit b338364

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

pkg/machine/gvproxy.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package machine
22

33
import (
4+
"errors"
45
"fmt"
6+
"io/fs"
57
"strconv"
68

79
"github.com/containers/podman/v5/pkg/machine/define"
@@ -11,7 +13,12 @@ import (
1113
func CleanupGVProxy(f define.VMFile) error {
1214
gvPid, err := f.Read()
1315
if err != nil {
14-
return fmt.Errorf("unable to read gvproxy pid file %s: %v", f.GetPath(), err)
16+
// The file will also be removed by gvproxy when it exits so
17+
// we need to account for the race and can just ignore it here.
18+
if errors.Is(err, fs.ErrNotExist) {
19+
return nil
20+
}
21+
return fmt.Errorf("unable to read gvproxy pid file: %v", err)
1522
}
1623
proxyPid, err := strconv.Atoi(string(gvPid))
1724
if err != nil {

pkg/machine/shim/host.go

+3-6
Original file line numberDiff line numberDiff line change
@@ -342,12 +342,9 @@ func Stop(mc *vmconfigs.MachineConfig, mp vmconfigs.VMProvider, dirs *machineDef
342342
if err != nil {
343343
return err
344344
}
345-
346-
defer func() {
347-
if err := machine.CleanupGVProxy(*gvproxyPidFile); err != nil {
348-
logrus.Errorf("unable to clean up gvproxy: %q", err)
349-
}
350-
}()
345+
if err := machine.CleanupGVProxy(*gvproxyPidFile); err != nil {
346+
return fmt.Errorf("unable to clean up gvproxy: %w", err)
347+
}
351348
}
352349

353350
return nil

0 commit comments

Comments
 (0)