providers/docker: process-level lock on copying default Vagrantfile

This commit is contained in:
Mitchell Hashimoto 2014-04-15 14:03:51 -07:00
parent dc2f729fd3
commit 144c874b5a
2 changed files with 12 additions and 3 deletions

View File

@ -373,7 +373,7 @@ module Vagrant
# Mark that we have a lock
@locks[name] = true
yield
return yield
ensure
# We need to make sure that no matter what this is always
# reset to false so we don't think we have a lock when we

View File

@ -52,8 +52,17 @@ module VagrantPlugins
# we don't write into our installation dir (we can't).
default_path = File.expand_path("../hostmachine/Vagrantfile", __FILE__)
vf_path = @machine.env.data_dir.join("docker-host", "Vagrantfile")
begin
if !vf_path.file?
@machine.env.lock("docker-provider-hostvm") do
vf_path.dirname.mkpath
FileUtils.cp(default_path, vf_path)
end
end
rescue Vagrant::Errors::EnvironmentLockedError
# Lock contention, just retry
retry
end
# Set the machine name since we hardcode that for the default
host_machine_name = :default