Fix a bug in manifest backfill that made it only work on active tags
This commit is contained in:
parent
cb637e1233
commit
0035a1ec6d
3 changed files with 7 additions and 8 deletions
|
@ -726,9 +726,7 @@ def get_possibly_expired_tag(namespace, repo_name, tag_name):
|
|||
.where(RepositoryTag.name == tag_name, Repository.name == repo_name,
|
||||
Namespace.username == namespace)).get()
|
||||
|
||||
|
||||
def associate_generated_tag_manifest(namespace, repo_name, tag_name, manifest, storage_id_map):
|
||||
tag = get_active_tag(namespace, repo_name, tag_name)
|
||||
def associate_generated_tag_manifest_with_tag(tag, manifest, storage_id_map):
|
||||
try:
|
||||
manifest = TagManifest.get(digest=manifest.digest)
|
||||
manifest.tag = tag
|
||||
|
@ -744,7 +742,7 @@ def associate_generated_tag_manifest(namespace, repo_name, tag_name, manifest, s
|
|||
.join(TagToRepositoryTag)
|
||||
.where(TagToRepositoryTag.repository_tag == tag)).get()
|
||||
except Tag.DoesNotExist:
|
||||
oci_tag = Tag.create(repository=tag.repository, manifest=oci_manifest, name=tag_name,
|
||||
oci_tag = Tag.create(repository=tag.repository, manifest=oci_manifest, name=tag.name,
|
||||
reversion=tag.reversion,
|
||||
lifetime_start_ms=tag.lifetime_start_ts * 1000,
|
||||
lifetime_end_ms=(tag.lifetime_end_ts * 1000
|
||||
|
|
|
@ -483,8 +483,8 @@ class PreOCIModel(SharedModel, RegistryDataInterface):
|
|||
|
||||
storage_map = {blob.content_checksum: blob.id for blob in blob_query}
|
||||
try:
|
||||
tag_manifest, _ = model.tag.associate_generated_tag_manifest(namespace_name, repo_name,
|
||||
tag.name, manifest, storage_map)
|
||||
tag_manifest, _ = model.tag.associate_generated_tag_manifest_with_tag(tag_obj, manifest,
|
||||
storage_map)
|
||||
assert tag_manifest
|
||||
except IntegrityError:
|
||||
tag_manifest = model.tag.get_tag_manifest(tag_obj)
|
||||
|
|
|
@ -435,14 +435,15 @@ def clear_rows(initialized_db):
|
|||
])
|
||||
def test_backfill_manifest_for_tag(repo_namespace, repo_name, clear_rows, pre_oci_model):
|
||||
repository_ref = pre_oci_model.lookup_repository(repo_namespace, repo_name)
|
||||
tags = pre_oci_model.list_repository_tags(repository_ref)
|
||||
tags, has_more = pre_oci_model.list_repository_tag_history(repository_ref, size=2500)
|
||||
assert tags
|
||||
assert not has_more
|
||||
|
||||
for tag in tags:
|
||||
assert not tag.manifest_digest
|
||||
assert pre_oci_model.backfill_manifest_for_tag(tag)
|
||||
|
||||
tags = pre_oci_model.list_repository_tags(repository_ref, include_legacy_images=True)
|
||||
tags, _ = pre_oci_model.list_repository_tag_history(repository_ref)
|
||||
assert tags
|
||||
for tag in tags:
|
||||
assert tag.manifest_digest
|
||||
|
|
Reference in a new issue