Merge pull request #3339 from quay/fix-backfill-bug
Fix a bug in manifest backfill that made it only work on active tags
This commit is contained in:
commit
ed75daf3d9
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,
|
.where(RepositoryTag.name == tag_name, Repository.name == repo_name,
|
||||||
Namespace.username == namespace)).get()
|
Namespace.username == namespace)).get()
|
||||||
|
|
||||||
|
def associate_generated_tag_manifest_with_tag(tag, manifest, storage_id_map):
|
||||||
def associate_generated_tag_manifest(namespace, repo_name, tag_name, manifest, storage_id_map):
|
|
||||||
tag = get_active_tag(namespace, repo_name, tag_name)
|
|
||||||
try:
|
try:
|
||||||
manifest = TagManifest.get(digest=manifest.digest)
|
manifest = TagManifest.get(digest=manifest.digest)
|
||||||
manifest.tag = tag
|
manifest.tag = tag
|
||||||
|
@ -744,7 +742,7 @@ def associate_generated_tag_manifest(namespace, repo_name, tag_name, manifest, s
|
||||||
.join(TagToRepositoryTag)
|
.join(TagToRepositoryTag)
|
||||||
.where(TagToRepositoryTag.repository_tag == tag)).get()
|
.where(TagToRepositoryTag.repository_tag == tag)).get()
|
||||||
except Tag.DoesNotExist:
|
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,
|
reversion=tag.reversion,
|
||||||
lifetime_start_ms=tag.lifetime_start_ts * 1000,
|
lifetime_start_ms=tag.lifetime_start_ts * 1000,
|
||||||
lifetime_end_ms=(tag.lifetime_end_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}
|
storage_map = {blob.content_checksum: blob.id for blob in blob_query}
|
||||||
try:
|
try:
|
||||||
tag_manifest, _ = model.tag.associate_generated_tag_manifest(namespace_name, repo_name,
|
tag_manifest, _ = model.tag.associate_generated_tag_manifest_with_tag(tag_obj, manifest,
|
||||||
tag.name, manifest, storage_map)
|
storage_map)
|
||||||
assert tag_manifest
|
assert tag_manifest
|
||||||
except IntegrityError:
|
except IntegrityError:
|
||||||
tag_manifest = model.tag.get_tag_manifest(tag_obj)
|
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):
|
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)
|
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 tags
|
||||||
|
assert not has_more
|
||||||
|
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
assert not tag.manifest_digest
|
assert not tag.manifest_digest
|
||||||
assert pre_oci_model.backfill_manifest_for_tag(tag)
|
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
|
assert tags
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
assert tag.manifest_digest
|
assert tag.manifest_digest
|
||||||
|
|
Reference in a new issue