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
|
@ -6,6 +6,7 @@ from peewee import JOIN, fn, IntegrityError
|
|||
from app import app
|
||||
from data.database import (UseThenDisconnect, TagManifest, TagManifestToManifest, Image,
|
||||
db_transaction)
|
||||
from data.model.image import get_parent_images
|
||||
from data.model.tag import populate_manifest
|
||||
from image.docker.schema1 import (DockerSchema1Manifest, ManifestException, ManifestInterface,
|
||||
DOCKER_SCHEMA1_SIGNED_MANIFEST_CONTENT_TYPE)
|
||||
|
@ -124,10 +125,12 @@ def backfill_manifest(tag_manifest):
|
|||
|
||||
# Lookup the storages for the digests.
|
||||
root_image = tag_manifest.tag.image
|
||||
storage_id_map = {root_image.storage.content_checksum: root_image.storage.id}
|
||||
for parent_image_id in root_image.ancestor_id_list():
|
||||
storage = Image.get(id=parent_image_id).storage
|
||||
storage_id_map[storage.content_checksum] = storage.id
|
||||
repository = tag_manifest.tag.repository
|
||||
|
||||
storage_ids = {root_image.storage.id}
|
||||
parent_images = get_parent_images(repository.namespace_user.username, repository.name, root_image)
|
||||
for parent_image in parent_images:
|
||||
storage_ids.add(parent_image.storage.id)
|
||||
|
||||
with db_transaction():
|
||||
# Re-retrieve the tag manifest to ensure it still exists and we're pointing at the correct tag.
|
||||
|
@ -138,7 +141,7 @@ def backfill_manifest(tag_manifest):
|
|||
|
||||
# Create the new-style rows for the manifest.
|
||||
manifest_row = populate_manifest(tag_manifest.tag.repository, manifest,
|
||||
tag_manifest.tag.image, storage_id_map)
|
||||
tag_manifest.tag.image, storage_ids)
|
||||
|
||||
# Create the mapping row. If we find another was created for this tag manifest in the
|
||||
# meantime, then we've been preempted.
|
||||
|
@ -150,7 +153,6 @@ def backfill_manifest(tag_manifest):
|
|||
return False
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.config.fileConfig(logfile_path(debug=False), disable_existing_loggers=False)
|
||||
worker = ManifestBackfillWorker()
|
||||
|
|
Reference in a new issue