From 48f3ce58807465366b8ad42777e2d83a8f2aeaaa Mon Sep 17 00:00:00 2001 From: Cody Herriges Date: Wed, 21 Sep 2011 13:27:23 -0700 Subject: [PATCH 1/2] Makes the execute method honor max_tries. Vagrant::SSH.execute is hard coded for only 5 tries, this makes starting Debian machines very unreliable. Debian will reset networking when you create a new hostonly NIC or change the hostname of the machine and occasionally the coming up part takes longer than what is provided by 5 tries. Making this method honor the max_tries config option will make it possible to avoid this. --- lib/vagrant/ssh.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vagrant/ssh.rb b/lib/vagrant/ssh.rb index 3b811a7fd..84563714a 100644 --- a/lib/vagrant/ssh.rb +++ b/lib/vagrant/ssh.rb @@ -98,7 +98,7 @@ module Vagrant exceptions = [Errno::ECONNREFUSED, Net::SSH::Disconnect] # Connect to SSH and gather the session - session = retryable(:tries => 5, :on => exceptions) do + session = retryable(:tries => env.config.ssh.max_tries, :on => exceptions) do connection = Net::SSH.start(env.config.ssh.host, env.config.ssh.username, opts.merge( :keys => [env.config.ssh.private_key_path], From f9c485bf0520acc33c3e5f2118e2386f32fa9fdc Mon Sep 17 00:00:00 2001 From: Cody Herriges Date: Thu, 29 Sep 2011 15:35:07 -0700 Subject: [PATCH 2/2] Should honor max_tries. Identified another place where ssh.max_tries was not being used where is likely should be. --- lib/vagrant/ssh/session.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vagrant/ssh/session.rb b/lib/vagrant/ssh/session.rb index fe80192c7..d68862a1e 100644 --- a/lib/vagrant/ssh/session.rb +++ b/lib/vagrant/ssh/session.rb @@ -61,7 +61,7 @@ module Vagrant # the actual `exec!` implementation, except that this # implementation also reports `:exit_status` to the block if given. def exec!(commands, options=nil, &block) - retryable(:tries => 5, :on => [IOError, Net::SSH::Disconnect], :sleep => 1.0) do + retryable(:tries => env.config.ssh.max_tries, :on => [IOError, Net::SSH::Disconnect], :sleep => 1.0) do metach = session.open_channel do |ch| ch.exec("#{env.config.ssh.shell} -l") do |ch2, success| # Set the terminal