providers/docker: process-level lock on copying default Vagrantfile
This commit is contained in:
parent
dc2f729fd3
commit
144c874b5a
|
@ -373,7 +373,7 @@ module Vagrant
|
||||||
# Mark that we have a lock
|
# Mark that we have a lock
|
||||||
@locks[name] = true
|
@locks[name] = true
|
||||||
|
|
||||||
yield
|
return yield
|
||||||
ensure
|
ensure
|
||||||
# We need to make sure that no matter what this is always
|
# 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
|
# reset to false so we don't think we have a lock when we
|
||||||
|
|
|
@ -52,8 +52,17 @@ module VagrantPlugins
|
||||||
# we don't write into our installation dir (we can't).
|
# we don't write into our installation dir (we can't).
|
||||||
default_path = File.expand_path("../hostmachine/Vagrantfile", __FILE__)
|
default_path = File.expand_path("../hostmachine/Vagrantfile", __FILE__)
|
||||||
vf_path = @machine.env.data_dir.join("docker-host", "Vagrantfile")
|
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
|
vf_path.dirname.mkpath
|
||||||
FileUtils.cp(default_path, vf_path)
|
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
|
# Set the machine name since we hardcode that for the default
|
||||||
host_machine_name = :default
|
host_machine_name = :default
|
||||||
|
|
Loading…
Reference in New Issue