Skip to content

Commit

Permalink
Add retry to correct for latency if public ip not yet populated Fixes d…
Browse files Browse the repository at this point in the history
  • Loading branch information
utkonos committed Dec 4, 2024
1 parent 7e3418d commit 708b1c8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/vagrant-digitalocean/actions/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,13 @@ def call(env)
@machine.id = result['droplet']['id'].to_s

# refresh droplet state with provider and output ip address
droplet = Provider.droplet(@machine, :refresh => true)
public_network = droplet['networks']['v4'].find { |network| network['type'] == 'public' }
droplet = nil
public_network = nil
retryable(:tries => 10, :sleep => 5) do
droplet = Provider.droplet(@machine, :refresh => true)
public_network = droplet['networks']['v4'].find { |network| network['type'] == 'public' }
raise 'Public network IP not yet available' unless public_network && public_network['ip_address']
end
private_network = droplet['networks']['v4'].find { |network| network['type'] == 'private' }
env[:ui].info I18n.t('vagrant_digital_ocean.info.droplet_ip', :ip => public_network['ip_address'])
if private_network
Expand Down

0 comments on commit 708b1c8

Please sign in to comment.