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):
|
def get_repository_blob_by_digest(repository, blob_digest):
|
||||||
""" Find the content-addressable blob linked to the specified repository.
|
""" Find the content-addressable blob linked to the specified repository.
|
||||||
"""
|
"""
|
||||||
|
assert blob_digest
|
||||||
try:
|
try:
|
||||||
storage = (ImageStorage
|
storage = (ImageStorage
|
||||||
.select(ImageStorage.uuid)
|
.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):
|
def get_repo_blob_by_digest(namespace, repo_name, blob_digest):
|
||||||
""" Find the content-addressable blob linked to the specified repository.
|
""" Find the content-addressable blob linked to the specified repository.
|
||||||
"""
|
"""
|
||||||
|
assert blob_digest
|
||||||
try:
|
try:
|
||||||
storage = (ImageStorage
|
storage = (ImageStorage
|
||||||
.select(ImageStorage.uuid)
|
.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
|
""" Temporarily links to the blob record from the given namespace. If the blob record is not
|
||||||
found, return None.
|
found, return None.
|
||||||
"""
|
"""
|
||||||
|
assert blob_digest
|
||||||
|
|
||||||
with db_transaction():
|
with db_transaction():
|
||||||
try:
|
try:
|
||||||
storage = ImageStorage.get(content_checksum=blob_digest)
|
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
|
globally accessible, such as the special empty gzipped tar layer that Docker
|
||||||
no longer pushes to us.
|
no longer pushes to us.
|
||||||
"""
|
"""
|
||||||
|
assert digest
|
||||||
try:
|
try:
|
||||||
return ImageStorage.get(content_checksum=digest, uploading=False)
|
return ImageStorage.get(content_checksum=digest, uploading=False)
|
||||||
except ImageStorage.DoesNotExist:
|
except ImageStorage.DoesNotExist:
|
||||||
|
|
|
@ -489,7 +489,8 @@ def find_or_create_derived_storage(source_image, transformation_name, preferred_
|
||||||
transformation=trans, uniqueness_hash=uniqueness_hash)
|
transformation=trans, uniqueness_hash=uniqueness_hash)
|
||||||
except IntegrityError:
|
except IntegrityError:
|
||||||
# Storage was created while this method executed. Just return the existing.
|
# 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 find_derived_storage_for_image(source_image, transformation_name, varying_metadata)
|
||||||
|
|
||||||
return derived
|
return derived
|
||||||
|
|
|
@ -189,7 +189,7 @@ def garbage_collect_storage(storage_id_whitelist):
|
||||||
|
|
||||||
|
|
||||||
def create_v1_storage(location_name):
|
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)
|
location = get_image_location_for_name(location_name)
|
||||||
ImageStoragePlacement.create(location=location.id, storage=storage)
|
ImageStoragePlacement.create(location=location.id, storage=storage)
|
||||||
storage.locations = {location_name}
|
storage.locations = {location_name}
|
||||||
|
|
Reference in a new issue