core: if can't communicate, force halt right away

This commit is contained in:
Mitchell Hashimoto 2014-02-23 22:25:59 -08:00
parent 8bb0094113
commit 4c070a04d2
2 changed files with 16 additions and 11 deletions

View File

@ -44,23 +44,23 @@ module Vagrant
# Only attempt to perform graceful shutdown under certain cases
# checked above.
if graceful
env[:ui].info I18n.t("vagrant.actions.vm.halt.graceful")
env[:ui].output(I18n.t("vagrant.actions.vm.halt.graceful"))
begin
env[:machine].guest.capability(:halt)
rescue Errors::MachineGuestNotReady
@logger.info("Machine guest not ready while attempting to halt. Ignoring.")
end
@logger.debug("Waiting for target graceful halt state: #{@target_state}")
begin
Timeout.timeout(env[:machine].config.vm.graceful_halt_timeout) do
while env[:machine].state.id != @target_state
sleep 1
@logger.debug("Waiting for target graceful halt state: #{@target_state}")
begin
Timeout.timeout(env[:machine].config.vm.graceful_halt_timeout) do
while env[:machine].state.id != @target_state
sleep 1
end
end
rescue Timeout::Error
# Don't worry about it, we catch the case later.
end
rescue Timeout::Error
# Don't worry about it, we catch the case later.
rescue Errors::MachineGuestNotReady
env[:ui].detail(I18n.t("vagrant.actions.vm.halt.guest_not_ready"))
end
# The result of this matters on whether we reached our

View File

@ -1312,6 +1312,11 @@ en:
Forcing shutdown of VM...
graceful: |-
Attempting graceful shutdown of VM...
guest_not_ready: |-
Guest communication could not be established! This is usually because
SSH is not running, the authentication information was changed,
or some other networking issue. Vagrant will force halt, if
capable.
hostname:
setting: "Setting hostname..."
import: