Merge pull request #388 from electrofelix/fix-parallel-up

Fixes #387: Break from mutex synchronize before calling next action
This commit is contained in:
Dmitry Vasilets 2015-06-08 17:19:30 +02:00
commit 65f14f4fe6
2 changed files with 11 additions and 6 deletions

View File

@ -37,9 +37,12 @@ module VagrantPlugins
env[:box_volume_name] = env[:machine].box.name.to_s.dup.gsub("/", "-VAGRANTSLASH-")
env[:box_volume_name] << "_vagrant_box_image_#{env[:machine].box.version.to_s rescue ''}.img"
# while inside the synchronize block take care not to call the next
# action in the chain, as must exit this block first to prevent
# locking all subsequent actions as well.
@@lock.synchronize do
# Don't continue if image already exists in storage pool.
return @app.call(env) if ProviderLibvirt::Util::Collection.find_matching(
break if ProviderLibvirt::Util::Collection.find_matching(
env[:libvirt_compute].volumes.all, env[:box_volume_name])
# Box is not available as a storage pool volume. Create and upload

View File

@ -14,14 +14,16 @@ module VagrantPlugins
end
def call(env)
@@lock.synchronize do
# Get config options.
config = env[:machine].provider_config
# Get config options.
config = env[:machine].provider_config
# while inside the synchronize block take care not to call the next
# action in the chain, as must exit this block first to prevent
# locking all subsequent actions as well.
@@lock.synchronize do
# Check for storage pool, where box image should be created
fog_pool = ProviderLibvirt::Util::Collection.find_matching(
break if ProviderLibvirt::Util::Collection.find_matching(
env[:libvirt_compute].pools.all, config.storage_pool_name)
return @app.call(env) if fog_pool
@logger.info("No storage pool '#{config.storage_pool_name}' is available.")