Skip to content

Commit

Permalink
SSH communicator - Reset retries counter, sleep between connection at…
Browse files Browse the repository at this point in the history
…tempts
  • Loading branch information
mc-slava committed Apr 10, 2021
1 parent 5bc3cdc commit 83ea9c0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions plugins/communicators/ssh/communicator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}")
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 83ea9c0

Please sign in to comment.