Add worker to backfill the new manifest tables from the tagmanifest table
This commit is contained in:
parent
805e928dff
commit
03ea3a3250
3 changed files with 241 additions and 7 deletions
|
@ -605,12 +605,21 @@ def associate_generated_tag_manifest(namespace, repo_name, tag_name, manifest, s
|
|||
|
||||
|
||||
def _create_manifest(tag, manifest, storage_id_map):
|
||||
media_type = Manifest.media_type.get_id(manifest.media_type)
|
||||
manifest_row = populate_manifest(tag.repository, manifest, tag.image, storage_id_map)
|
||||
|
||||
with db_transaction():
|
||||
manifest_row = Manifest.create(digest=manifest.digest, repository=tag.repository,
|
||||
tag_manifest = TagManifest.create(tag=tag, digest=manifest.digest, json_data=manifest.bytes)
|
||||
TagManifestToManifest.create(tag_manifest=tag_manifest, manifest=manifest_row)
|
||||
return tag_manifest
|
||||
|
||||
|
||||
def populate_manifest(repository, manifest, legacy_image, storage_id_map):
|
||||
""" 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():
|
||||
manifest_row = Manifest.create(digest=manifest.digest, repository=repository,
|
||||
manifest_bytes=manifest.bytes, media_type=media_type)
|
||||
ManifestLegacyImage.create(manifest=manifest_row, repository=tag.repository, image=tag.image)
|
||||
ManifestLegacyImage.create(manifest=manifest_row, repository=repository, image=legacy_image)
|
||||
|
||||
blobs_to_insert = []
|
||||
blobs_created = set()
|
||||
|
@ -623,16 +632,14 @@ def _create_manifest(tag, manifest, storage_id_map):
|
|||
if image_storage_id in blobs_created:
|
||||
continue
|
||||
|
||||
blobs_to_insert.append(dict(manifest=manifest_row, repository=tag.repository,
|
||||
blobs_to_insert.append(dict(manifest=manifest_row, repository=repository,
|
||||
blob=image_storage_id))
|
||||
blobs_created.add(image_storage_id)
|
||||
|
||||
if blobs_to_insert:
|
||||
ManifestBlob.insert_many(blobs_to_insert).execute()
|
||||
|
||||
tag_manifest = TagManifest.create(tag=tag, digest=manifest.digest, json_data=manifest.bytes)
|
||||
TagManifestToManifest.create(tag_manifest=tag_manifest, manifest=manifest_row)
|
||||
return tag_manifest
|
||||
return manifest_row
|
||||
|
||||
|
||||
def load_tag_manifest(namespace, repo_name, tag_name):
|
||||
|
|
Reference in a new issue