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:
Joseph Schorr 2019-02-20 17:20:32 -05:00 committed by GitHub
commit b5a5ce7c43
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 24 deletions

View file

@ -727,12 +727,6 @@ 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)
with db_transaction():
@ -750,7 +744,7 @@ def associate_generated_tag_manifest_with_tag(tag, manifest, storage_id_map):
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):

View file

@ -482,7 +482,7 @@ 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,
tag_manifest = model.tag.associate_generated_tag_manifest_with_tag(tag_obj, manifest,
storage_map)
assert tag_manifest
except IntegrityError: