Merge pull request #3370 from quay/delete-image-placements

Make sure to delete the image placements in the manifest builder cleanup code
This commit is contained in:
Joseph Schorr 2019-02-16 12:39:19 -05:00 committed by GitHub
commit 127174fcf7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View file

@ -7,7 +7,7 @@ from collections import namedtuple
from flask import session
from data import model
from data.database import db_transaction, ImageStorage
from data.database import db_transaction, ImageStorage, ImageStoragePlacement
from data.registry_model import registry_model
from image.docker.schema2 import EMPTY_LAYER_BLOB_DIGEST
@ -203,6 +203,10 @@ class _ManifestBuilder(object):
try:
storage = ImageStorage.get(id=storage_id)
if storage.uploading and storage.content_checksum != EMPTY_LAYER_BLOB_DIGEST:
# Delete all the placements pointing to the storage.
ImageStoragePlacement.delete().where(ImageStoragePlacement.storage == storage).execute()
# Delete the storage.
storage.delete_instance()
except ImageStorage.DoesNotExist:
pass

View file

@ -67,6 +67,9 @@ def test_build_manifest(layers, fake_session, registry_model):
assert tag
assert tag in builder.committed_tags
# Mark the builder as done.
builder.done()
# Verify the legacy image for the tag.
found = registry_model.get_repo_tag(repository_ref, 'somenewtag', include_legacy_image=True)
assert found