diff --git a/plugins/communicators/ssh/communicator.rb b/plugins/communicators/ssh/communicator.rb index d5e5e66587f..206933baed5 100644 --- a/plugins/communicators/ssh/communicator.rb +++ b/plugins/communicators/ssh/communicator.rb @@ -40,7 +40,8 @@ class Communicator < Vagrant.plugin("2", :communicator) Errno::EHOSTUNREACH, Errno::EPIPE, Net::SSH::Disconnect, - Timeout::Error + Timeout::Error, + Net::SSH::Exception ] include Vagrant::Util::ANSIEscapeCodeRemover @@ -84,7 +85,7 @@ def wait_for_ready(timeout) message = nil begin begin - connect(retries: 1) + connect return true if ready? rescue Vagrant::Errors::VagrantError => e @logger.info("SSH not ready: #{e.inspect}") @@ -429,7 +430,7 @@ def connect(**opts) timeout = 60 @logger.info("Attempting SSH connection...") - connection = retryable(tries: opts[:retries], on: SSH_RETRY_EXCEPTIONS) do + connection = retryable(tries: opts[:retries], on: SSH_RETRY_EXCEPTIONS, sleep: 5) do Timeout.timeout(timeout) do begin # This logger will get the Net-SSH log data for us. @@ -515,6 +516,9 @@ def connect(**opts) raise Vagrant::Errors::SSHKeyTypeNotSupported end + @logger.debug("Resetting retries counter") + opts.delete(:retries) if opts.key?(:retries) + @connection = connection @connection_ssh_info = ssh_info