Merge pull request #3380 from quay/joseph.schorr/QUAY-1353/always-new-tag-manifest
Always create a new tag manifest row when backfilling in the old data model
This commit is contained in:
commit
b5a5ce7c43
2 changed files with 18 additions and 24 deletions
|
@ -727,30 +727,24 @@ def get_possibly_expired_tag(namespace, repo_name, tag_name):
|
|||
Namespace.username == namespace)).get()
|
||||
|
||||
def associate_generated_tag_manifest_with_tag(tag, manifest, storage_id_map):
|
||||
try:
|
||||
manifest = TagManifest.get(digest=manifest.digest)
|
||||
manifest.tag = tag
|
||||
manifest.save()
|
||||
return manifest, False
|
||||
except TagManifest.DoesNotExist:
|
||||
oci_manifest = _populate_manifest_and_blobs(tag.repository, manifest, storage_id_map)
|
||||
oci_manifest = _populate_manifest_and_blobs(tag.repository, manifest, storage_id_map)
|
||||
|
||||
with db_transaction():
|
||||
try:
|
||||
(Tag
|
||||
.select()
|
||||
.join(TagToRepositoryTag)
|
||||
.where(TagToRepositoryTag.repository_tag == tag)).get()
|
||||
except Tag.DoesNotExist:
|
||||
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
|
||||
if tag.lifetime_end_ts else None),
|
||||
tag_kind=Tag.tag_kind.get_id('tag'))
|
||||
TagToRepositoryTag.create(tag=oci_tag, repository_tag=tag, repository=tag.repository)
|
||||
with db_transaction():
|
||||
try:
|
||||
(Tag
|
||||
.select()
|
||||
.join(TagToRepositoryTag)
|
||||
.where(TagToRepositoryTag.repository_tag == tag)).get()
|
||||
except Tag.DoesNotExist:
|
||||
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
|
||||
if tag.lifetime_end_ts else None),
|
||||
tag_kind=Tag.tag_kind.get_id('tag'))
|
||||
TagToRepositoryTag.create(tag=oci_tag, repository_tag=tag, repository=tag.repository)
|
||||
|
||||
return _associate_manifest(tag, oci_manifest), True
|
||||
return _associate_manifest(tag, oci_manifest)
|
||||
|
||||
|
||||
def _associate_manifest(tag, oci_manifest):
|
||||
|
|
|
@ -482,8 +482,8 @@ class PreOCIModel(SharedModel, RegistryDataInterface):
|
|||
blob_query = self._lookup_repo_storages_by_content_checksum(repo, manifest.checksums)
|
||||
storage_map = {blob.content_checksum: blob.id for blob in blob_query}
|
||||
try:
|
||||
tag_manifest, _ = model.tag.associate_generated_tag_manifest_with_tag(tag_obj, 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)
|
||||
|
|
Reference in a new issue