mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[compute|aws] improve consistency of waiting for ssh to be ready
This commit is contained in:
parent
a67a1cf1b3
commit
7ae749c2c3
1 changed files with 9 additions and 8 deletions
|
@ -177,19 +177,20 @@ module Fog
|
|||
if public_key
|
||||
commands << %{echo "#{public_key}" >> ~/.ssh/authorized_keys}
|
||||
end
|
||||
# allow some retries over the first 120 seconds because aws is weird
|
||||
|
||||
# wait for aws to be ready
|
||||
Timeout::timeout(120) do
|
||||
begin
|
||||
Timeout::timeout(4) do
|
||||
Fog::SSH.new(public_ip_address, username, credentials).run(commands)
|
||||
end
|
||||
rescue Net::SSH::AuthenticationFailed, Timeout::Error
|
||||
Fog::SSH.new(public_ip_address, username, credentials.merge(:timeout => 4)).run('pwd')
|
||||
rescue Errno::ECONNREFUSED
|
||||
sleep(2)
|
||||
retry
|
||||
rescue Net::SSH::AuthenticationFailed, Timeout::Error => e
|
||||
p e
|
||||
retry
|
||||
end
|
||||
end
|
||||
rescue Errno::ECONNREFUSED => e
|
||||
sleep(1)
|
||||
retry
|
||||
Fog::SSH.new(public_ip_address, username, credentials).run(commands)
|
||||
end
|
||||
|
||||
def ssh(commands)
|
||||
|
|
Loading…
Add table
Reference in a new issue