mirror of
				https://github.com/containers/podman.git
				synced 2025-11-04 00:50:15 +08:00 
			
		
		
		
	Merge pull request #21786 from Luap99/machine-gvproxy-cleanup
pkg/machine: ignore gvproxy pidfile not exists error
This commit is contained in:
		@ -1,7 +1,9 @@
 | 
				
			|||||||
package machine
 | 
					package machine
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
 | 
						"errors"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
 | 
						"io/fs"
 | 
				
			||||||
	"strconv"
 | 
						"strconv"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/containers/podman/v5/pkg/machine/define"
 | 
						"github.com/containers/podman/v5/pkg/machine/define"
 | 
				
			||||||
@ -11,7 +13,12 @@ import (
 | 
				
			|||||||
func CleanupGVProxy(f define.VMFile) error {
 | 
					func CleanupGVProxy(f define.VMFile) error {
 | 
				
			||||||
	gvPid, err := f.Read()
 | 
						gvPid, err := f.Read()
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return fmt.Errorf("unable to read gvproxy pid file %s: %v", f.GetPath(), err)
 | 
							// 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))
 | 
						proxyPid, err := strconv.Atoi(string(gvPid))
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
 | 
				
			|||||||
@ -342,12 +342,9 @@ func Stop(mc *vmconfigs.MachineConfig, mp vmconfigs.VMProvider, dirs *machineDef
 | 
				
			|||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return err
 | 
								return err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					 | 
				
			||||||
		defer func() {
 | 
					 | 
				
			||||||
		if err := machine.CleanupGVProxy(*gvproxyPidFile); err != nil {
 | 
							if err := machine.CleanupGVProxy(*gvproxyPidFile); err != nil {
 | 
				
			||||||
				logrus.Errorf("unable to clean up gvproxy: %q", err)
 | 
								return fmt.Errorf("unable to clean up gvproxy: %w", err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		}()
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user