Merge pull request #1706 from coreos-inc/fix-duplicate-cache

Fix duplicate derived storage cache creation issue
This commit is contained in:
josephschorr 2016-08-10 16:46:09 -04:00 committed by GitHub
commit cbfa77b114

View file

@ -505,8 +505,15 @@ def find_or_create_derived_storage(source_image, transformation_name, preferred_
uniqueness_hash = _get_uniqueness_hash(varying_metadata)
trans = ImageStorageTransformation.get(name=transformation_name)
new_storage = storage.create_v1_storage(preferred_location)
DerivedStorageForImage.create(source_image=source_image, derivative=new_storage,
transformation=trans, uniqueness_hash=uniqueness_hash)
try:
DerivedStorageForImage.create(source_image=source_image, derivative=new_storage,
transformation=trans, uniqueness_hash=uniqueness_hash)
except IntegrityError:
# Storage was created while this method executed. Just return the existing.
new_storage.delete_instance(recursive=True)
return find_derived_storage_for_image(source_image, transformation_name, varying_metadata)
return new_storage