Make absolutely sure we don't overwrite an existing storage checksum
Old V1 code would occasionally do so, which was never correct, but we never hit it because we didn't (practically) share storage rows before. Now that we explicitly do, we were occasionally de-checksum-ing storage rows on V1 pushes (which are extremely rare as-is). This change makes sure we don't do that, and makes sure we always set a proper digest and checksum on storage rows.
This commit is contained in:
parent
127174fcf7
commit
59e4896dbf
2 changed files with 6 additions and 3 deletions
|
@ -52,6 +52,8 @@ 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.
|
||||
"""
|
||||
assert blob_digest
|
||||
|
||||
with db_transaction():
|
||||
try:
|
||||
storage = ImageStorage.get(content_checksum=blob_digest)
|
||||
|
@ -183,6 +185,10 @@ def get_or_create_shared_blob(digest, byte_data, storage):
|
|||
accessible, such as the special empty gzipped tar layer that Docker
|
||||
no longer pushes to us.
|
||||
"""
|
||||
assert digest
|
||||
assert byte_data is not None
|
||||
assert storage
|
||||
|
||||
try:
|
||||
return ImageStorage.get(content_checksum=digest, uploading=False)
|
||||
except ImageStorage.DoesNotExist:
|
||||
|
|
|
@ -341,9 +341,6 @@ def set_image_metadata(docker_image_id, namespace_name, repository_name, created
|
|||
|
||||
# We cleanup any old checksum in case it's a retry after a fail
|
||||
fetched.v1_checksum = None
|
||||
fetched.storage.content_checksum = None
|
||||
fetched.storage.save()
|
||||
|
||||
fetched.comment = comment
|
||||
fetched.command = command
|
||||
fetched.v1_json_metadata = v1_json_metadata
|
||||
|
|
Reference in a new issue