Commit c58d5ab3 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

builder/virtualbox: time out on SSH handshake for retry

parent 5c0d8ecd
...@@ -9,8 +9,8 @@ import ( ...@@ -9,8 +9,8 @@ import (
func testConfig() map[string]interface{} { func testConfig() map[string]interface{} {
return map[string]interface{}{ return map[string]interface{}{
"iso_md5": "foo", "iso_md5": "foo",
"iso_url": "http://www.google.com/", "iso_url": "http://www.google.com/",
"ssh_username": "foo", "ssh_username": "foo",
} }
} }
......
...@@ -115,10 +115,25 @@ func (s *stepWaitForSSH) waitForSSH(state map[string]interface{}) (packer.Commun ...@@ -115,10 +115,25 @@ func (s *stepWaitForSSH) waitForSSH(state map[string]interface{}) (packer.Commun
}, },
} }
comm, err = ssh.New(nc, sshConfig) sshConnectSuccess := make(chan bool, 1)
if err != nil { go func() {
log.Printf("SSH connection fail: %s", err) comm, err = ssh.New(nc, sshConfig)
nc.Close() if err != nil {
log.Printf("SSH connection fail: %s", err)
sshConnectSuccess <- false
return
}
sshConnectSuccess <- true
}()
select {
case success := <-sshConnectSuccess:
if !success {
continue
}
case <-time.After(5 * time.Second):
log.Printf("SSH handshake timeout. Trying again.")
continue continue
} }
......
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