Merge pull request #8565 from chrisroberts/fix/ssh-errors

Update hyperv and docker providers to raise exception on SSH when machine is not ready
This commit is contained in:
Chris Roberts 2017-05-08 10:04:23 -07:00 committed by GitHub
commit c2dc79567e
4 changed files with 20 additions and 15 deletions

View File

@ -177,14 +177,12 @@ module VagrantPlugins
Vagrant::Action::Builder.new.tap do |b|
b.use Call, IsState, :not_created do |env, b2|
if env[:result]
b2.use Message, I18n.t("docker_provider.messages.not_created")
next
raise Errors::ContainerNotCreatedError
end
b2.use Call, IsState, :running do |env2, b3|
if !env2[:result]
b3.use Message, I18n.t("docker_provider.messages.not_running")
next
raise Errors::ContainerNotRunningError
end
b3.use PrepareSSH
@ -199,13 +197,12 @@ module VagrantPlugins
Vagrant::Action::Builder.new.tap do |b|
b.use Call, IsState, :not_created do |env, b2|
if env[:result]
b2.use Message, I18n.t("docker_provider.messages.not_created")
next
raise Errors::ContainerNotCreatedError
end
b2.use Call, IsState, :running do |env2, b3|
if !env2[:result]
raise Vagrant::Errors::VMNotRunningError
raise Errors::ContainerNotRunningError
end
b3.use SSHRun

View File

@ -9,6 +9,14 @@ module VagrantPlugins
error_key(:communicator_non_docker)
end
class ContainerNotRunningError < DockerError
error_key(:not_running)
end
class ContainerNotCreatedError < DockerError
error_key(:not_created)
end
class ExecuteError < DockerError
error_key(:execute_error)
end

View File

@ -178,14 +178,12 @@ module VagrantPlugins
b.use ConfigValidate
b.use Call, IsState, :not_created do |env, b2|
if env[:result]
b2.use Message, I18n.t("vagrant_hyperv.message_not_created")
next
raise Vagrant::Errors::VMNotCreatedError
end
b2.use Call, IsState, :running do |env1, b3|
if !env1[:result]
b3.use Message, I18n.t("vagrant_hyperv.message_not_running")
next
raise Vagrant::Errors::VMNotRunningError
end
b3.use SSHExec
@ -199,14 +197,12 @@ module VagrantPlugins
b.use ConfigValidate
b.use Call, IsState, :not_created do |env, b2|
if env[:result]
b2.use Message, I18n.t("vagrant_hyperv.message_not_created")
next
raise Vagrant::Errors::VMNotCreatedError
end
b2.use Call, IsState, :running do |env1, b3|
if !env1[:result]
b3.use Message, I18n.t("vagrant_hyperv.message_not_running")
next
raise Vagrant::Errors::VMNotRunningError
end
b3.use SSHRun

View File

@ -117,6 +117,10 @@ en:
run exits and doesn't keep running.
errors:
not_created: |-
The container hasn't been created yet.
not_running: |-
The container is not currently running.
communicator_non_docker: |-
The "docker_hostvm" communicator was specified on a machine that
is not provided by the Docker provider. This is a bug with your