Make sure to delete the image placements in the manifest builder cleanup code
This commit is contained in:
parent
f2a351183a
commit
4a22a52aee
2 changed files with 8 additions and 1 deletions
|
@ -7,7 +7,7 @@ from collections import namedtuple
|
||||||
from flask import session
|
from flask import session
|
||||||
|
|
||||||
from data import model
|
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 data.registry_model import registry_model
|
||||||
from image.docker.schema2 import EMPTY_LAYER_BLOB_DIGEST
|
from image.docker.schema2 import EMPTY_LAYER_BLOB_DIGEST
|
||||||
|
|
||||||
|
@ -203,6 +203,10 @@ class _ManifestBuilder(object):
|
||||||
try:
|
try:
|
||||||
storage = ImageStorage.get(id=storage_id)
|
storage = ImageStorage.get(id=storage_id)
|
||||||
if storage.uploading and storage.content_checksum != EMPTY_LAYER_BLOB_DIGEST:
|
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()
|
storage.delete_instance()
|
||||||
except ImageStorage.DoesNotExist:
|
except ImageStorage.DoesNotExist:
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -67,6 +67,9 @@ def test_build_manifest(layers, fake_session, registry_model):
|
||||||
assert tag
|
assert tag
|
||||||
assert tag in builder.committed_tags
|
assert tag in builder.committed_tags
|
||||||
|
|
||||||
|
# Mark the builder as done.
|
||||||
|
builder.done()
|
||||||
|
|
||||||
# Verify the legacy image for the tag.
|
# Verify the legacy image for the tag.
|
||||||
found = registry_model.get_repo_tag(repository_ref, 'somenewtag', include_legacy_image=True)
|
found = registry_model.get_repo_tag(repository_ref, 'somenewtag', include_legacy_image=True)
|
||||||
assert found
|
assert found
|
||||||
|
|
Reference in a new issue