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
Ability to work with Instances over SSH tunnel. #1091
Conversation
"#{ssh_gateway_username}@#{ssh_gateway}") | ||
Net::SSH::Gateway.new(ssh_gateway, | ||
ssh_gateway_username, options).ssh(hostname, username, options) | ||
rescue *RESCUE_EXCEPTIONS_ON_ESTABLISH => e |
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.
Would be great if we could reuse the retry logic accross the two connection strategies.
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.
I tried. Look at this commit d171410. But rubocop was very unhappy -(
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.
Looks like you hat the gateway and non-gateway connection with the retry all in one method there. I think you did the right thing be making separate methods but I'd suggest extracting the retry logic which appears to be identical in both to be something like:
def retry_connection(opts)
yield
# RESCUE CODE HERE
end
Then
def establish_connection_via_gateway(opts)
retry_connection(opts) do
Net::SSH::Gateway.new(ssh_gateway,
ssh_gateway_username, options).ssh(hostname, username, options)
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.
Thanks for the hint! Moved the code. Although now we have comments describing parameters identical for three methods -(
👍 |
1 similar comment
+1 |
Inspired by:
#294
#933
In your .kitchen.yml file you use:
and all ssh operations will be tunnelled through this .
Basically we replace Net::SSH session in transport/ssh.rb with Net::SSH::Gateway, since this moment all ssh operations go through the tunnel. Remote end 'not being ready' also reported correctly: