From d1b316554590faaf809e83d119a6bd2dece61740 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 17 Apr 2014 17:11:00 -0700 Subject: [PATCH] providers/docker: cleaner action stacks --- plugins/providers/docker/action.rb | 19 ++++++++++++++++++- plugins/providers/docker/provider.rb | 4 +++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/plugins/providers/docker/action.rb b/plugins/providers/docker/action.rb index 83374163b..31315ba15 100644 --- a/plugins/providers/docker/action.rb +++ b/plugins/providers/docker/action.rb @@ -9,8 +9,25 @@ module VagrantPlugins def self.action_up Vagrant::Action::Builder.new.tap do |b| b.use ConfigValidate - b.use HandleBox + + b.use Call, IsState, :not_created do |env, b2| + if env[:result] + b2.use HandleBox + end + end + b.use HostMachine + + # Yeah, this is supposed to be here twice (once more above). This + # catches the case when the container was supposed to be created, + # but the host state was unknown, and now we know its not actually + # created. + b.use Call, IsState, :not_created do |env, b2| + if env[:result] + b2.use HandleBox + end + end + b.use action_start end end diff --git a/plugins/providers/docker/provider.rb b/plugins/providers/docker/provider.rb index 81fcd7e56..cc5df52b8 100644 --- a/plugins/providers/docker/provider.rb +++ b/plugins/providers/docker/provider.rb @@ -141,7 +141,9 @@ module VagrantPlugins def state state_id = nil - state_id = :host_state_unknown if host_vm? && !host_vm.communicate.ready? + state_id = :not_created if !@machine.id + state_id = :host_state_unknown if !state_id && \ + host_vm? && !host_vm.communicate.ready? state_id = :not_created if !state_id && \ (!@machine.id || !driver.created?(@machine.id)) state_id = driver.state(@machine.id) if @machine.id && !state_id