Skip to content

Commit

Permalink
ensure image is not removed before the container -> leads to problems
Browse files Browse the repository at this point in the history
  • Loading branch information
Michel Käser committed Aug 11, 2015
1 parent 6127adc commit a645b06
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
14 changes: 0 additions & 14 deletions ipynbsrv/core/signals/container_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,6 @@ def create_image_on_server(sender, container, image, **kwargs):
raise ex


@receiver(container_deleted)
def delete_internal_image_if_latest(sender, container, **kwargs):
"""
Delete the internal only image if this is the last container using it.
"""
if container is not None:
try:
if container.is_image_based() and container.image.is_internal and not container.has_clones():
if not Container.objects.filter(image=container.image).exists():
container.image.delete()
except ContainerImage.DoesNotExist:
pass


@receiver(container_image_deleted)
def delete_related_notifications(sender, image, **kwargs):
"""
Expand Down
4 changes: 4 additions & 0 deletions ipynbsrv/core/signals/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ def delete_on_server(sender, container, **kwargs):
if container is not None:
try:
container.server.get_container_backend().delete_container(container.backend_pk)
# cleanup internal images
if container.is_image_based() and container.image.is_internal and not container.has_clones():
if not Container.objects.filter(image=container.image).exists():
container.image.delete()
except ContainerNotFoundError as ex:
pass # already deleted
except ContainerBackendError as ex:
Expand Down

0 comments on commit a645b06

Please sign in to comment.