Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSH communicator - Reset retries counter, sleep between connection attempts #12292

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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