Merge pull request #3377 from quay/joseph.schorr/QUAY-1350/additional-storage-assertions
Add additional assertions and further checks in storage code
This commit is contained in:
commit
96083956b9
3 changed files with 8 additions and 2 deletions
|
@ -15,6 +15,7 @@ logger = logging.getLogger(__name__)
|
|||
def get_repository_blob_by_digest(repository, blob_digest):
|
||||
""" Find the content-addressable blob linked to the specified repository.
|
||||
"""
|
||||
assert blob_digest
|
||||
try:
|
||||
storage = (ImageStorage
|
||||
.select(ImageStorage.uuid)
|
||||
|
@ -32,6 +33,7 @@ def get_repository_blob_by_digest(repository, blob_digest):
|
|||
def get_repo_blob_by_digest(namespace, repo_name, blob_digest):
|
||||
""" Find the content-addressable blob linked to the specified repository.
|
||||
"""
|
||||
assert blob_digest
|
||||
try:
|
||||
storage = (ImageStorage
|
||||
.select(ImageStorage.uuid)
|
||||
|
@ -81,6 +83,8 @@ def temp_link_blob(namespace, repo_name, blob_digest, link_expiration_s):
|
|||
""" Temporarily links to the blob record from the given namespace. If the blob record is not
|
||||
found, return None.
|
||||
"""
|
||||
assert blob_digest
|
||||
|
||||
with db_transaction():
|
||||
try:
|
||||
storage = ImageStorage.get(content_checksum=blob_digest)
|
||||
|
@ -172,6 +176,7 @@ def get_shared_blob(digest):
|
|||
globally accessible, such as the special empty gzipped tar layer that Docker
|
||||
no longer pushes to us.
|
||||
"""
|
||||
assert digest
|
||||
try:
|
||||
return ImageStorage.get(content_checksum=digest, uploading=False)
|
||||
except ImageStorage.DoesNotExist:
|
||||
|
|
|
@ -489,7 +489,8 @@ def find_or_create_derived_storage(source_image, transformation_name, preferred_
|
|||
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)
|
||||
ImageStoragePlacement.delete().where(ImageStoragePlacement.storage == new_storage).execute()
|
||||
new_storage.delete_instance()
|
||||
return find_derived_storage_for_image(source_image, transformation_name, varying_metadata)
|
||||
|
||||
return derived
|
||||
|
|
|
@ -189,7 +189,7 @@ def garbage_collect_storage(storage_id_whitelist):
|
|||
|
||||
|
||||
def create_v1_storage(location_name):
|
||||
storage = ImageStorage.create(cas_path=False)
|
||||
storage = ImageStorage.create(cas_path=False, uploading=True)
|
||||
location = get_image_location_for_name(location_name)
|
||||
ImageStoragePlacement.create(location=location.id, storage=storage)
|
||||
storage.locations = {location_name}
|
||||
|
|
Reference in a new issue