-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Added config.ssh.retries and config.ssh.retry_interval to allow for SSH retries #13047
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ module VagrantPlugins | |
module Kernel_V2 | ||
class SSHConnectConfig < Vagrant.plugin("2", :config) | ||
DEFAULT_SSH_CONNECT_TIMEOUT = 15 | ||
DEFAULT_SSH_RETRIES = 5 | ||
DEFAULT_SSH_RETRY_INTERVAL = 10 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This number can probably come down some. The winrm communicator uses 2. |
||
|
||
attr_accessor :host | ||
attr_accessor :port | ||
|
@@ -18,6 +20,8 @@ class SSHConnectConfig < Vagrant.plugin("2", :config) | |
attr_accessor :dsa_authentication | ||
attr_accessor :extra_args | ||
attr_accessor :remote_user | ||
attr_accessor :retries | ||
attr_accessor :retry_interval | ||
|
||
def initialize | ||
@host = UNSET_VALUE | ||
|
@@ -35,6 +39,8 @@ def initialize | |
@dsa_authentication = UNSET_VALUE | ||
@extra_args = UNSET_VALUE | ||
@remote_user = UNSET_VALUE | ||
@retries = UNSET_VALUE | ||
@retry_interval = UNSET_VALUE | ||
end | ||
|
||
def finalize! | ||
|
@@ -52,6 +58,8 @@ def finalize! | |
@extra_args = nil if @extra_args == UNSET_VALUE | ||
@config = nil if @config == UNSET_VALUE | ||
@connect_timeout = DEFAULT_SSH_CONNECT_TIMEOUT if @connect_timeout == UNSET_VALUE | ||
@retries = DEFAULT_SSH_RETRIES if @retries == UNSET_VALUE | ||
@retry_interval = DEFAULT_SSH_RETRY_INTERVAL if @retry_interval == UNSET_VALUE | ||
|
||
if @private_key_path && !@private_key_path.is_a?(Array) | ||
@private_key_path = [@private_key_path] | ||
|
@@ -134,6 +142,26 @@ def validate(machine) | |
given: @connect_timeout.to_s) | ||
end | ||
|
||
if !@retries.is_a?(Integer) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Take a look at the |
||
errors << I18n.t( | ||
"vagrant.config.ssh.retries_invalid_type", | ||
given: @retries.class.name) | ||
elsif @retries < 1 | ||
errors << I18n.t( | ||
"vagrant.config.ssh.retries_invalid_value", | ||
given: @retries.to_s) | ||
end | ||
|
||
if !@retry_interval.is_a?(Integer) | ||
errors << I18n.t( | ||
"vagrant.config.ssh.retry_interval_invalid_type", | ||
given: @retry_interval.class.name) | ||
elsif @retry_interval < 1 | ||
errors << I18n.t( | ||
"vagrant.config.ssh.retry_interval_invalid_value", | ||
given: @retry_interval.to_s) | ||
end | ||
|
||
errors | ||
end | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the
ssh_info
should probably already have the default value for the retries (coming from the config). So, there is no need to default this again. Instead, this can beopts[:retries] = ssh_info[:retries] if !opts.key?(:retries)
(same for the retry_interval below). This also implies that the internal caller of this method can override the user defined config.This also means that the
ssh_info
method in theMachine
class needs to be updated to account for this new config.