mirror of
https://github.com/containers/podman.git
synced 2025-05-20 00:27:03 +08:00
Clean up gvproxy if machine start fails
Matt found a bug where if a machine start did not run to completion, a gvproxy was left around running. This gvproxy then subsequently stopped the next attempt to start. Signed-off-by: Brent Baude <bbaude@redhat.com> [NO NEW TESTS NEEDED]
This commit is contained in:
@ -55,7 +55,7 @@ func (c *CleanupCallback) clean() {
|
||||
}
|
||||
}
|
||||
|
||||
func InitCleanup() CleanupCallback {
|
||||
func CleanUp() CleanupCallback {
|
||||
return CleanupCallback{
|
||||
Funcs: []func() error{},
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ func (h HyperVStubber) CreateVM(opts define.CreateVMOpts, mc *vmconfigs.MachineC
|
||||
var (
|
||||
err error
|
||||
)
|
||||
callbackFuncs := machine.InitCleanup()
|
||||
callbackFuncs := machine.CleanUp()
|
||||
defer callbackFuncs.CleanIfErr(&err)
|
||||
go callbackFuncs.CleanOnSignal()
|
||||
|
||||
@ -182,7 +182,7 @@ func (h HyperVStubber) StartVM(mc *vmconfigs.MachineConfig) (func() error, func(
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
callbackFuncs := machine.InitCleanup()
|
||||
callbackFuncs := machine.CleanUp()
|
||||
defer callbackFuncs.CleanIfErr(&err)
|
||||
go callbackFuncs.CleanOnSignal()
|
||||
|
||||
@ -384,7 +384,7 @@ func (h HyperVStubber) PostStartNetworking(mc *vmconfigs.MachineConfig, noInfo b
|
||||
err error
|
||||
executable string
|
||||
)
|
||||
callbackFuncs := machine.InitCleanup()
|
||||
callbackFuncs := machine.CleanUp()
|
||||
defer callbackFuncs.CleanIfErr(&err)
|
||||
go callbackFuncs.CleanOnSignal()
|
||||
|
||||
|
@ -70,7 +70,7 @@ func Init(opts machineDefine.InitOptions, mp vmconfigs.VMProvider) (*vmconfigs.M
|
||||
imagePath *machineDefine.VMFile
|
||||
)
|
||||
|
||||
callbackFuncs := machine.InitCleanup()
|
||||
callbackFuncs := machine.CleanUp()
|
||||
defer callbackFuncs.CleanIfErr(&err)
|
||||
go callbackFuncs.CleanOnSignal()
|
||||
|
||||
@ -350,15 +350,31 @@ func Stop(mc *vmconfigs.MachineConfig, mp vmconfigs.VMProvider, dirs *machineDef
|
||||
return nil
|
||||
}
|
||||
|
||||
func Start(mc *vmconfigs.MachineConfig, mp vmconfigs.VMProvider, _ *machineDefine.MachineDirs, opts machine.StartOptions) error {
|
||||
func Start(mc *vmconfigs.MachineConfig, mp vmconfigs.VMProvider, dirs *machineDefine.MachineDirs, opts machine.StartOptions) error {
|
||||
defaultBackoff := 500 * time.Millisecond
|
||||
maxBackoffs := 6
|
||||
|
||||
gvproxyPidFile, err := dirs.RuntimeDir.AppendToNewVMFile("gvproxy.pid", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// start gvproxy and set up the API socket forwarding
|
||||
forwardSocketPath, forwardingState, err := startNetworking(mc, mp)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
callBackFuncs := machine.CleanUp()
|
||||
defer callBackFuncs.CleanIfErr(&err)
|
||||
go callBackFuncs.CleanOnSignal()
|
||||
|
||||
// Clean up gvproxy if start fails
|
||||
cleanGV := func() error {
|
||||
return machine.CleanupGVProxy(*gvproxyPidFile)
|
||||
}
|
||||
callBackFuncs.Add(cleanGV)
|
||||
|
||||
// if there are generic things that need to be done, a preStart function could be added here
|
||||
// should it be extensive
|
||||
|
||||
|
@ -31,7 +31,7 @@ func (w WSLStubber) CreateVM(opts define.CreateVMOpts, mc *vmconfigs.MachineConf
|
||||
err error
|
||||
)
|
||||
// cleanup half-baked files if init fails at any point
|
||||
callbackFuncs := machine.InitCleanup()
|
||||
callbackFuncs := machine.CleanUp()
|
||||
defer callbackFuncs.CleanIfErr(&err)
|
||||
go callbackFuncs.CleanOnSignal()
|
||||
mc.WSLHypervisor = new(vmconfigs.WSLConfig)
|
||||
|
Reference in New Issue
Block a user