Fix manifest backfill for manifests pointing to V1 images
V1 images don't have checksums, so we just always use the full storage set for the manifest, rather than a checksum map
This commit is contained in:
parent
73e585df49
commit
96e0fc4ad6
3 changed files with 24 additions and 25 deletions
|
@ -605,7 +605,19 @@ def associate_generated_tag_manifest(namespace, repo_name, tag_name, manifest, s
|
|||
|
||||
|
||||
def _create_manifest(tag, manifest, storage_id_map):
|
||||
manifest_row = populate_manifest(tag.repository, manifest, tag.image, storage_id_map)
|
||||
storage_ids = set()
|
||||
for blob_digest in reversed(manifest.blob_digests):
|
||||
image_storage_id = storage_id_map.get(blob_digest)
|
||||
if image_storage_id is None:
|
||||
logger.error('Missing blob for manifest `%s` in: %s', blob_digest, storage_id_map)
|
||||
raise DataModelException('Missing blob for manifest `%s`' % blob_digest)
|
||||
|
||||
if image_storage_id in storage_ids:
|
||||
continue
|
||||
|
||||
storage_ids.add(image_storage_id)
|
||||
|
||||
manifest_row = populate_manifest(tag.repository, manifest, tag.image, storage_ids)
|
||||
|
||||
with db_transaction():
|
||||
tag_manifest = TagManifest.create(tag=tag, digest=manifest.digest, json_data=manifest.bytes)
|
||||
|
@ -613,7 +625,7 @@ def _create_manifest(tag, manifest, storage_id_map):
|
|||
return tag_manifest
|
||||
|
||||
|
||||
def populate_manifest(repository, manifest, legacy_image, storage_id_map):
|
||||
def populate_manifest(repository, manifest, legacy_image, storage_ids):
|
||||
""" Populates the rows for the manifest, including its blobs and legacy image. """
|
||||
media_type = Manifest.media_type.get_id(manifest.media_type)
|
||||
with db_transaction():
|
||||
|
@ -621,21 +633,8 @@ def populate_manifest(repository, manifest, legacy_image, storage_id_map):
|
|||
manifest_bytes=manifest.bytes, media_type=media_type)
|
||||
ManifestLegacyImage.create(manifest=manifest_row, repository=repository, image=legacy_image)
|
||||
|
||||
blobs_to_insert = []
|
||||
blobs_created = set()
|
||||
for blob_digest in reversed(manifest.blob_digests):
|
||||
image_storage_id = storage_id_map.get(blob_digest)
|
||||
if image_storage_id is None:
|
||||
logger.error('Missing blob for manifest `%s` in: %s', blob_digest, storage_id_map)
|
||||
raise DataModelException('Missing blob for manifest `%s`' % blob_digest)
|
||||
|
||||
if image_storage_id in blobs_created:
|
||||
continue
|
||||
|
||||
blobs_to_insert.append(dict(manifest=manifest_row, repository=repository,
|
||||
blob=image_storage_id))
|
||||
blobs_created.add(image_storage_id)
|
||||
|
||||
blobs_to_insert = [dict(manifest=manifest_row, repository=repository,
|
||||
blob=storage_id) for storage_id in storage_ids]
|
||||
if blobs_to_insert:
|
||||
ManifestBlob.insert_many(blobs_to_insert).execute()
|
||||
|
||||
|
|
Reference in a new issue