Merge pull request #1706 from coreos-inc/fix-duplicate-cache
Fix duplicate derived storage cache creation issue
This commit is contained in:
commit
cbfa77b114
1 changed files with 9 additions and 2 deletions
|
@ -505,8 +505,15 @@ def find_or_create_derived_storage(source_image, transformation_name, preferred_
|
||||||
uniqueness_hash = _get_uniqueness_hash(varying_metadata)
|
uniqueness_hash = _get_uniqueness_hash(varying_metadata)
|
||||||
trans = ImageStorageTransformation.get(name=transformation_name)
|
trans = ImageStorageTransformation.get(name=transformation_name)
|
||||||
new_storage = storage.create_v1_storage(preferred_location)
|
new_storage = storage.create_v1_storage(preferred_location)
|
||||||
|
|
||||||
|
try:
|
||||||
DerivedStorageForImage.create(source_image=source_image, derivative=new_storage,
|
DerivedStorageForImage.create(source_image=source_image, derivative=new_storage,
|
||||||
transformation=trans, uniqueness_hash=uniqueness_hash)
|
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
|
return new_storage
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in a new issue