builder/vmware: Handle interrupts while waiting for SSH
This commit is contained in:
parent
be1e60aa26
commit
174ae65a12
|
@ -44,6 +44,10 @@ func (s *stepWaitForSSH) Run(state map[string]interface{}) multistep.StepAction
|
|||
|
||||
log.Printf("Waiting for SSH, up to timeout: %s", config.SSHWaitTimeout.String())
|
||||
|
||||
timeout := time.After(config.SSHWaitTimeout)
|
||||
for {
|
||||
// Wait for either SSH to become available, a timeout to occur,
|
||||
// or an interrupt to come through.
|
||||
select {
|
||||
case <-waitDone:
|
||||
if err != nil {
|
||||
|
@ -52,10 +56,17 @@ func (s *stepWaitForSSH) Run(state map[string]interface{}) multistep.StepAction
|
|||
}
|
||||
|
||||
state["communicator"] = comm
|
||||
case <-time.After(config.SSHWaitTimeout):
|
||||
break
|
||||
case <-timeout:
|
||||
ui.Error("Timeout waiting for SSH.")
|
||||
s.cancel = true
|
||||
return multistep.ActionHalt
|
||||
case <-time.After(1 * time.Second):
|
||||
if _, ok := state[multistep.StateCancelled]; ok {
|
||||
log.Println("Interrupt detected, quitting waiting for SSH.")
|
||||
return multistep.ActionHalt
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return multistep.ActionContinue
|
||||
|
|
Loading…
Reference in New Issue