Implement support for blob mounting via the mount
parameter on blob uploads
Fixes https://jira.coreos.com/browse/QUAY-893
This commit is contained in:
parent
44bb000fa5
commit
0fa1a1d5fd
5 changed files with 179 additions and 8 deletions
|
@ -30,9 +30,7 @@ def store_blob_record_and_temp_link(namespace, repo_name, blob_digest, location_
|
|||
link_expiration_s, uncompressed_byte_count=None):
|
||||
""" Store a record of the blob and temporarily link it to the specified repository.
|
||||
"""
|
||||
random_image_name = str(uuid4())
|
||||
with db_transaction():
|
||||
repo = _basequery.get_existing_repository(namespace, repo_name)
|
||||
try:
|
||||
storage = ImageStorage.get(content_checksum=blob_digest)
|
||||
storage.image_size = byte_count
|
||||
|
@ -51,12 +49,33 @@ def store_blob_record_and_temp_link(namespace, repo_name, blob_digest, location_
|
|||
except ImageStoragePlacement.DoesNotExist:
|
||||
ImageStoragePlacement.create(storage=storage, location=location_obj)
|
||||
|
||||
# Create a temporary link into the repository, to be replaced by the v1 metadata later
|
||||
# and create a temporary tag to reference it
|
||||
image = Image.create(storage=storage, docker_image_id=random_image_name, repository=repo)
|
||||
tag.create_temporary_hidden_tag(repo, image, link_expiration_s)
|
||||
_temp_link_blob(namespace, repo_name, storage, link_expiration_s)
|
||||
return storage
|
||||
|
||||
return storage
|
||||
|
||||
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.
|
||||
"""
|
||||
with db_transaction():
|
||||
try:
|
||||
storage = ImageStorage.get(content_checksum=blob_digest)
|
||||
except ImageStorage.DoesNotExist:
|
||||
return None
|
||||
|
||||
_temp_link_blob(namespace, repo_name, storage, link_expiration_s)
|
||||
return storage
|
||||
|
||||
|
||||
def _temp_link_blob(namespace, repo_name, storage, link_expiration_s):
|
||||
""" Note: Should *always* be called by a parent under a transaction. """
|
||||
random_image_name = str(uuid4())
|
||||
repo = _basequery.get_existing_repository(namespace, repo_name)
|
||||
|
||||
# Create a temporary link into the repository, to be replaced by the v1 metadata later
|
||||
# and create a temporary tag to reference it
|
||||
image = Image.create(storage=storage, docker_image_id=random_image_name, repository=repo)
|
||||
tag.create_temporary_hidden_tag(repo, image, link_expiration_s)
|
||||
|
||||
|
||||
def get_stale_blob_upload(stale_timespan):
|
||||
|
|
Reference in a new issue