Merge pull request #3397 from quay/joseph.schorr/QUAY-1418/fix-v1-push
Fix V1 push for layers already uploaded
This commit is contained in:
commit
d3dd2f7b7c
4 changed files with 35 additions and 10 deletions
|
@ -55,16 +55,23 @@ def store_blob_record_and_temp_link(namespace, repo_name, blob_digest, location_
|
||||||
""" Store a record of the blob and temporarily link it to the specified repository.
|
""" Store a record of the blob and temporarily link it to the specified repository.
|
||||||
"""
|
"""
|
||||||
assert blob_digest
|
assert blob_digest
|
||||||
|
assert byte_count is not None
|
||||||
|
|
||||||
with db_transaction():
|
with db_transaction():
|
||||||
try:
|
try:
|
||||||
storage = ImageStorage.get(content_checksum=blob_digest)
|
storage = ImageStorage.get(content_checksum=blob_digest)
|
||||||
storage.image_size = byte_count
|
save_changes = False
|
||||||
|
|
||||||
if uncompressed_byte_count is not None:
|
if storage.image_size is None:
|
||||||
|
storage.image_size = byte_count
|
||||||
|
save_changes = True
|
||||||
|
|
||||||
|
if storage.uncompressed_size is None and uncompressed_byte_count is not None:
|
||||||
storage.uncompressed_size = uncompressed_byte_count
|
storage.uncompressed_size = uncompressed_byte_count
|
||||||
|
save_changes = True
|
||||||
|
|
||||||
storage.save()
|
if save_changes:
|
||||||
|
storage.save()
|
||||||
|
|
||||||
ImageStoragePlacement.get(storage=storage, location=location_obj)
|
ImageStoragePlacement.get(storage=storage, location=location_obj)
|
||||||
except ImageStorage.DoesNotExist:
|
except ImageStorage.DoesNotExist:
|
||||||
|
|
|
@ -21,8 +21,10 @@ def test_store_blob(initialized_db):
|
||||||
blob_storage2 = model.blob.store_blob_record_and_temp_link(ADMIN_ACCESS_USER, REPO, digest,
|
blob_storage2 = model.blob.store_blob_record_and_temp_link(ADMIN_ACCESS_USER, REPO, digest,
|
||||||
location, 2048, 0, 6000)
|
location, 2048, 0, 6000)
|
||||||
assert blob_storage2.id == blob_storage.id
|
assert blob_storage2.id == blob_storage.id
|
||||||
assert blob_storage2.image_size == 2048
|
|
||||||
assert blob_storage2.uncompressed_size == 6000
|
# The sizes should be unchanged.
|
||||||
|
assert blob_storage2.image_size == 1024
|
||||||
|
assert blob_storage2.uncompressed_size == 5000
|
||||||
|
|
||||||
# Add a new digest, ensure it has a new record.
|
# Add a new digest, ensure it has a new record.
|
||||||
otherdigest = 'anotherdigest'
|
otherdigest = 'anotherdigest'
|
||||||
|
|
|
@ -161,11 +161,6 @@ def put_image_layer(namespace, repository, image_id):
|
||||||
if repository_ref is None:
|
if repository_ref is None:
|
||||||
abort(403)
|
abort(403)
|
||||||
|
|
||||||
logger.debug('Retrieving image')
|
|
||||||
legacy_image = registry_model.get_legacy_image(repository_ref, image_id)
|
|
||||||
if legacy_image is not None and not legacy_image.uploading:
|
|
||||||
exact_abort(409, 'Image already exists')
|
|
||||||
|
|
||||||
logger.debug('Checking for image in manifest builder')
|
logger.debug('Checking for image in manifest builder')
|
||||||
builder = lookup_manifest_builder(repository_ref, session.get('manifest_builder'), store)
|
builder = lookup_manifest_builder(repository_ref, session.get('manifest_builder'), store)
|
||||||
if builder is None:
|
if builder is None:
|
||||||
|
|
|
@ -53,6 +53,27 @@ def test_empty_layer(pusher, puller, images_with_empty_layer, liveserver_session
|
||||||
credentials=credentials)
|
credentials=credentials)
|
||||||
|
|
||||||
|
|
||||||
|
def test_empty_layer_push_again(pusher, puller, images_with_empty_layer, liveserver_session,
|
||||||
|
app_reloader):
|
||||||
|
""" Test: Push and pull of an image with an empty layer to a new repository and then push it
|
||||||
|
again. """
|
||||||
|
credentials = ('devtable', 'password')
|
||||||
|
|
||||||
|
# Push a new repository.
|
||||||
|
pusher.push(liveserver_session, 'devtable', 'newrepo', 'latest', images_with_empty_layer,
|
||||||
|
credentials=credentials)
|
||||||
|
|
||||||
|
# Pull the repository to verify.
|
||||||
|
puller.pull(liveserver_session, 'devtable', 'newrepo', 'latest', images_with_empty_layer,
|
||||||
|
credentials=credentials)
|
||||||
|
|
||||||
|
# Push to the repository again, to ensure everything is skipped properly.
|
||||||
|
options = ProtocolOptions()
|
||||||
|
options.skip_head_checks = True
|
||||||
|
pusher.push(liveserver_session, 'devtable', 'newrepo', 'latest', images_with_empty_layer,
|
||||||
|
credentials=credentials, options=options)
|
||||||
|
|
||||||
|
|
||||||
def test_multi_layer_images_push_pull(pusher, puller, multi_layer_images, liveserver_session,
|
def test_multi_layer_images_push_pull(pusher, puller, multi_layer_images, liveserver_session,
|
||||||
app_reloader):
|
app_reloader):
|
||||||
""" Test: Basic push and pull of a multi-layered image to a new repository. """
|
""" Test: Basic push and pull of a multi-layered image to a new repository. """
|
||||||
|
|
Reference in a new issue