Retry connection on Net::SSH::Disconnect [closes GH-313]
This commit is contained in:
parent
5143556065
commit
52c5c79edf
|
@ -76,7 +76,12 @@ module Vagrant
|
|||
session, options = @current_session
|
||||
|
||||
if !session || options != opts
|
||||
session = retryable(:tries => 5, :on => Errno::ECONNREFUSED) do
|
||||
# The exceptions which are acceptable to retry on during
|
||||
# attempts to connect to SSH
|
||||
exceptions = [Errno::ECONNREFUSED, Net::SSH::Disconnect]
|
||||
|
||||
# Connect to SSH and gather the session
|
||||
session = retryable(:tries => 5, :on => exceptions) do
|
||||
connection = Net::SSH.start(env.config.ssh.host,
|
||||
env.config.ssh.username,
|
||||
opts.merge( :keys => [env.config.ssh.private_key_path],
|
||||
|
|
|
@ -203,13 +203,6 @@ class SshTest < Test::Unit::TestCase
|
|||
}
|
||||
end
|
||||
|
||||
should "return false if the connection is dropped" do
|
||||
Net::SSH.expects(:start).raises(Net::SSH::Disconnect)
|
||||
assert_nothing_raised {
|
||||
assert !@ssh.up?
|
||||
}
|
||||
end
|
||||
|
||||
should "specifity the timeout as an option to execute" do
|
||||
@ssh.expects(:execute).yields(true).with() do |opts|
|
||||
assert_equal @env.config.ssh.timeout, opts[:timeout]
|
||||
|
|
Loading…
Reference in New Issue