Merge pull request #19210 from vrothberg/fix-17403

machine start: qemu: wait for SSH readiness
This commit is contained in:
OpenShift Merge Robot
2023-07-13 15:37:46 +02:00
committed by GitHub

View File

@ -599,9 +599,14 @@ func (v *MachineVM) Start(name string, opts machine.StartOptions) error {
_ = v.writeConfig() _ = v.writeConfig()
} }
} }
if len(v.Mounts) > 0 { if len(v.Mounts) == 0 {
v.waitAPIAndPrintInfo(forwardState, forwardSock, opts.NoInfo)
return nil
}
connected := false connected := false
backoff = 500 * time.Millisecond backoff = defaultBackoff
var sshError error
for i := 0; i < maxBackoffs; i++ { for i := 0; i < maxBackoffs; i++ {
if i > 0 { if i > 0 {
time.Sleep(backoff) time.Sleep(backoff)
@ -612,14 +617,29 @@ func (v *MachineVM) Start(name string, opts machine.StartOptions) error {
return err return err
} }
if state == machine.Running && v.isListening() { if state == machine.Running && v.isListening() {
// Also make sure that SSH is up and running. The
// ready service's dependencies don't fully make sure
// that clients can SSH into the machine immediately
// after boot.
//
// CoreOS users have reported the same observation but
// the underlying source of the issue remains unknown.
if sshError = v.SSH(name, machine.SSHOptions{Args: []string{"true"}}); sshError != nil {
logrus.Debugf("SSH readiness check for machine failed: %v", sshError)
continue
}
connected = true connected = true
break break
} }
} }
if !connected { if !connected {
return fmt.Errorf("machine did not transition into running state") msg := "machine did not transition into running state"
if sshError != nil {
return fmt.Errorf("%s: ssh error: %v", msg, sshError)
} }
return errors.New(msg)
} }
for _, mount := range v.Mounts { for _, mount := range v.Mounts {
if !opts.Quiet { if !opts.Quiet {
fmt.Printf("Mounting volume... %s:%s\n", mount.Source, mount.Target) fmt.Printf("Mounting volume... %s:%s\n", mount.Source, mount.Target)