mirror of
https://github.com/containers/podman.git
synced 2025-06-26 04:46:57 +08:00
Workaround connection hangups in start/stop racing
Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
This commit is contained in:

committed by
Jason T. Greene

parent
09b86e26d1
commit
bb7d8fdc41
@ -6,6 +6,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/fs"
|
||||
"os"
|
||||
"os/exec"
|
||||
@ -266,6 +267,22 @@ func (q *QEMUStubber) State(mc *vmconfigs.MachineConfig, bypass bool) (define.St
|
||||
return "", err
|
||||
}
|
||||
if err := monitor.Connect(); err != nil {
|
||||
// There is a case where if we stop the same vm (from running) two
|
||||
// consecutive times we can get an econnreset when trying to get the
|
||||
// state
|
||||
if errors.Is(err, syscall.ECONNRESET) {
|
||||
// try again
|
||||
logrus.Debug("received ECCONNRESET from QEMU monitor; trying again")
|
||||
secondTry := monitor.Connect()
|
||||
if errors.Is(secondTry, io.EOF) {
|
||||
return define.Stopped, nil
|
||||
}
|
||||
if secondTry != nil {
|
||||
logrus.Debugf("second attempt to connect to QEMU monitor failed")
|
||||
return "", secondTry
|
||||
}
|
||||
}
|
||||
|
||||
return "", err
|
||||
}
|
||||
defer func() {
|
||||
|
Reference in New Issue
Block a user