core: config.vm.graceful_halt_timeout to specify graceful halt timeout
This commit is contained in:
parent
96ed15bad4
commit
c38fadfd2f
|
@ -5,6 +5,9 @@ BACKWARDS INCOMPATIBILITY:
|
||||||
- `config.ssh.max_tries` is gone. Instead of maximum tries, Vagrant now
|
- `config.ssh.max_tries` is gone. Instead of maximum tries, Vagrant now
|
||||||
uses a simple overall timeout value `config.ssh.timeout` to wait for
|
uses a simple overall timeout value `config.ssh.timeout` to wait for
|
||||||
the machine to boot up.
|
the machine to boot up.
|
||||||
|
- `config.vm.graceful_halt_retry_*` settings are gone. Instead, a single
|
||||||
|
timeout is now used to wait for a graceful halt to work, specified
|
||||||
|
by `config.vm.graceful_halt_timeout`.
|
||||||
|
|
||||||
FEATURES:
|
FEATURES:
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,7 @@ Vagrant.configure("2") do |config|
|
||||||
config.vm.usable_port_range = (2200..2250)
|
config.vm.usable_port_range = (2200..2250)
|
||||||
config.vm.box_url = nil
|
config.vm.box_url = nil
|
||||||
config.vm.base_mac = nil
|
config.vm.base_mac = nil
|
||||||
config.vm.graceful_halt_retry_count = 60
|
config.vm.graceful_halt_timeout = 60
|
||||||
config.vm.graceful_halt_retry_interval = 1
|
|
||||||
|
|
||||||
# Share SSH locally by default
|
# Share SSH locally by default
|
||||||
config.vm.network :forwarded_port,
|
config.vm.network :forwarded_port,
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
require "log4r"
|
require "log4r"
|
||||||
|
require "timeout"
|
||||||
|
|
||||||
module Vagrant
|
module Vagrant
|
||||||
module Action
|
module Action
|
||||||
|
@ -52,11 +53,14 @@ module Vagrant
|
||||||
end
|
end
|
||||||
|
|
||||||
@logger.debug("Waiting for target graceful halt state: #{@target_state}")
|
@logger.debug("Waiting for target graceful halt state: #{@target_state}")
|
||||||
count = 0
|
begin
|
||||||
while env[:machine].state.id != @target_state
|
Timeout.timeout(env[:machine].config.vm.graceful_halt_timeout) do
|
||||||
count += 1
|
while env[:machine].state.id != @target_state
|
||||||
return if count >= env[:machine].config.vm.graceful_halt_retry_count
|
sleep 1
|
||||||
sleep env[:machine].config.vm.graceful_halt_retry_interval
|
end
|
||||||
|
end
|
||||||
|
rescue Timeout::Error
|
||||||
|
# Don't worry about it, we catch the case later.
|
||||||
end
|
end
|
||||||
|
|
||||||
# The result of this matters on whether we reached our
|
# The result of this matters on whether we reached our
|
||||||
|
|
|
@ -18,8 +18,7 @@ module VagrantPlugins
|
||||||
attr_accessor :box
|
attr_accessor :box
|
||||||
attr_accessor :box_url
|
attr_accessor :box_url
|
||||||
attr_accessor :box_download_insecure
|
attr_accessor :box_download_insecure
|
||||||
attr_accessor :graceful_halt_retry_count
|
attr_accessor :graceful_halt_timeout
|
||||||
attr_accessor :graceful_halt_retry_interval
|
|
||||||
attr_accessor :guest
|
attr_accessor :guest
|
||||||
attr_accessor :hostname
|
attr_accessor :hostname
|
||||||
attr_accessor :usable_port_range
|
attr_accessor :usable_port_range
|
||||||
|
@ -27,8 +26,7 @@ module VagrantPlugins
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@box_download_insecure = UNSET_VALUE
|
@box_download_insecure = UNSET_VALUE
|
||||||
@graceful_halt_retry_count = UNSET_VALUE
|
@graceful_halt_timeout = UNSET_VALUE
|
||||||
@graceful_halt_retry_interval = UNSET_VALUE
|
|
||||||
@guest = UNSET_VALUE
|
@guest = UNSET_VALUE
|
||||||
@hostname = UNSET_VALUE
|
@hostname = UNSET_VALUE
|
||||||
@provisioners = []
|
@provisioners = []
|
||||||
|
@ -247,6 +245,7 @@ module VagrantPlugins
|
||||||
def finalize!
|
def finalize!
|
||||||
# Defaults
|
# Defaults
|
||||||
@box_download_insecure = false if @box_download_insecure == UNSET_VALUE
|
@box_download_insecure = false if @box_download_insecure == UNSET_VALUE
|
||||||
|
@graceful_halt_timeout = 300 if @graceful_halt_timeout == UNSET_VALUE
|
||||||
@guest = nil if @guest == UNSET_VALUE
|
@guest = nil if @guest == UNSET_VALUE
|
||||||
@hostname = nil if @hostname == UNSET_VALUE
|
@hostname = nil if @hostname == UNSET_VALUE
|
||||||
@hostname = @hostname.to_s if @hostname
|
@hostname = @hostname.to_s if @hostname
|
||||||
|
|
Loading…
Reference in New Issue