providers/docker: process-level lock on host machine up
This commit is contained in:
parent
afb61b1466
commit
c1f14320bd
|
@ -1,3 +1,5 @@
|
|||
require "digest/md5"
|
||||
|
||||
require "log4r"
|
||||
|
||||
require "vagrant/util/platform"
|
||||
|
@ -24,15 +26,30 @@ module VagrantPlugins
|
|||
env[:machine].ui.output(I18n.t(
|
||||
"docker_provider.host_machine_needed"))
|
||||
|
||||
# TODO(mitchellh): process-level lock so that we don't
|
||||
# step on parallel Vagrant's toes.
|
||||
|
||||
host_machine = env[:machine].provider.host_vm
|
||||
|
||||
# Grab a process-level lock on the data directory of this VM
|
||||
# so that we only try to spin up one at a time
|
||||
hash = Digest::MD5.hexdigest(host_machine.data_dir.to_s)
|
||||
begin
|
||||
env[:machine].env.lock(hash) do
|
||||
setup_host_machine(host_machine, env)
|
||||
end
|
||||
rescue Vagrant::Errors::EnvironmentLockedError
|
||||
sleep 1
|
||||
retry
|
||||
end
|
||||
|
||||
@app.call(env)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def setup_host_machine(host_machine, env)
|
||||
# See if the machine is ready already.
|
||||
if host_machine.communicate.ready?
|
||||
env[:machine].ui.detail(I18n.t("docker_provider.host_machine_ready"))
|
||||
return @app.call(env)
|
||||
return
|
||||
end
|
||||
|
||||
# Create a UI for this machine that stays at the detail level
|
||||
|
@ -47,8 +64,6 @@ module VagrantPlugins
|
|||
host_machine.with_ui(proxy_ui) do
|
||||
host_machine.action(:up)
|
||||
end
|
||||
|
||||
@app.call(env)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -528,9 +528,9 @@ module VagrantPlugins
|
|||
"--name", name,
|
||||
"--transient")
|
||||
|
||||
execute(
|
||||
"setextradata", @uuid,
|
||||
"VBoxInternal2/SharedFoldersEnableSymlinksCreate/#{name}")
|
||||
execute(
|
||||
"setextradata", @uuid,
|
||||
"VBoxInternal2/SharedFoldersEnableSymlinksCreate/#{name}")
|
||||
rescue Vagrant::Errors::VBoxManageError => e
|
||||
if e.extra_data[:stderr].include?("VBOX_E_FILE_ERROR")
|
||||
# The folder doesn't exist. ignore.
|
||||
|
|
Loading…
Reference in New Issue