Commit 174ae65a authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

builder/vmware: Handle interrupts while waiting for SSH

parent be1e60aa
......@@ -44,18 +44,29 @@ func (s *stepWaitForSSH) Run(state map[string]interface{}) multistep.StepAction
log.Printf("Waiting for SSH, up to timeout: %s", config.SSHWaitTimeout.String())
select {
case <-waitDone:
if err != nil {
ui.Error(fmt.Sprintf("Error waiting for SSH: %s", err))
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 {
ui.Error(fmt.Sprintf("Error waiting for SSH: %s", err))
return multistep.ActionHalt
}
state["communicator"] = comm
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
}
}
state["communicator"] = comm
case <-time.After(config.SSHWaitTimeout):
ui.Error("Timeout waiting for SSH.")
s.cancel = true
return multistep.ActionHalt
}
return multistep.ActionContinue
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment