Retry after create script execution and increase sleep time when trying to get container ip
Dont know why but I started getting a lot of timeouts so lets make the container scripts wait a bit more before failing.
This commit is contained in:
parent
ce0b40bbe9
commit
e8459de8cb
2 changed files with 11 additions and 13 deletions
|
@ -1,8 +1,3 @@
|
||||||
unless ENV['USER'] == 'vagrant'
|
|
||||||
puts 'This Gemfile is meant to be used from the dev box'
|
|
||||||
exit 1
|
|
||||||
end
|
|
||||||
|
|
||||||
source "https://rubygems.org"
|
source "https://rubygems.org"
|
||||||
|
|
||||||
gem 'vagrant-lxc', path: '../'
|
gem 'vagrant-lxc', path: '../'
|
||||||
|
|
|
@ -54,13 +54,16 @@ module Vagrant
|
||||||
private_key = Vagrant.source_root.join('keys', 'vagrant').expand_path.to_s
|
private_key = Vagrant.source_root.join('keys', 'vagrant').expand_path.to_s
|
||||||
|
|
||||||
@logger.debug 'Running after-create-script from box metadata'
|
@logger.debug 'Running after-create-script from box metadata'
|
||||||
cmd = [
|
|
||||||
script,
|
# TODO: Gotta write somewhere that it has to be indempotent
|
||||||
'-r', "#{CONTAINERS_PATH}/#{@name}/rootfs",
|
retryable(:tries => 5, :sleep => 1.5) do
|
||||||
'-k', private_key,
|
execute *[
|
||||||
'-i', dhcp_ip
|
script,
|
||||||
]
|
'-r', "#{CONTAINERS_PATH}/#{@name}/rootfs",
|
||||||
execute *cmd
|
'-k', private_key,
|
||||||
|
'-i', dhcp_ip
|
||||||
|
]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def start
|
def start
|
||||||
|
@ -101,7 +104,7 @@ module Vagrant
|
||||||
ip = ''
|
ip = ''
|
||||||
# Right after creation lxc reports the container as running
|
# Right after creation lxc reports the container as running
|
||||||
# before DNS is returning the right IP, so have to wait for a while
|
# before DNS is returning the right IP, so have to wait for a while
|
||||||
retryable(:on => LXC::Errors::ExecuteError, :tries => 10, :sleep => 1) do
|
retryable(:on => LXC::Errors::ExecuteError, :tries => 10, :sleep => 3) do
|
||||||
# By default LXC supplies a dns server on 10.0.3.1 so we request the IP
|
# By default LXC supplies a dns server on 10.0.3.1 so we request the IP
|
||||||
# of our target from there.
|
# of our target from there.
|
||||||
# Tks to: https://github.com/neerolyte/vagueant/blob/master/bin/vagueant#L340
|
# Tks to: https://github.com/neerolyte/vagueant/blob/master/bin/vagueant#L340
|
||||||
|
|
Loading…
Reference in a new issue