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

builder/vmware: Handle interrupts while waiting for SSH

parent be1e60aa
...@@ -44,6 +44,10 @@ func (s *stepWaitForSSH) Run(state map[string]interface{}) multistep.StepAction ...@@ -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()) 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 { select {
case <-waitDone: case <-waitDone:
if err != nil { if err != nil {
...@@ -52,10 +56,17 @@ func (s *stepWaitForSSH) Run(state map[string]interface{}) multistep.StepAction ...@@ -52,10 +56,17 @@ func (s *stepWaitForSSH) Run(state map[string]interface{}) multistep.StepAction
} }
state["communicator"] = comm state["communicator"] = comm
case <-time.After(config.SSHWaitTimeout): break
case <-timeout:
ui.Error("Timeout waiting for SSH.") ui.Error("Timeout waiting for SSH.")
s.cancel = true s.cancel = true
return multistep.ActionHalt 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 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