diff --git a/ipynbsrv/core/models.py b/ipynbsrv/core/models.py index cfb7193..7267a2e 100644 --- a/ipynbsrv/core/models.py +++ b/ipynbsrv/core/models.py @@ -544,6 +544,10 @@ def clean(self): raise ValidationError({ 'server': 'A clone can only be created on the same node as it\'s parent.' }) + if self.image and self.image.is_internal: + raise ValidationError({ + 'image': 'Internal images cannot be used to create containers from.' + }) super(Container, self).clean() def clone(self, name, description=None): diff --git a/ipynbsrv/core/signals/container_images.py b/ipynbsrv/core/signals/container_images.py index 16dcc8b..9a488fe 100644 --- a/ipynbsrv/core/signals/container_images.py +++ b/ipynbsrv/core/signals/container_images.py @@ -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): """ @@ -59,9 +45,10 @@ def delete_on_server(sender, image, **kwargs): backend.delete_container_image(image.backend_pk) except ContainerImageNotFoundError: pass # already removed - except ContainerBackendError as ex: + except ContainerBackendError: # XXX: restore? - raise ex + # raise ex + pass @receiver(post_delete, sender=ContainerImage) diff --git a/ipynbsrv/core/signals/containers.py b/ipynbsrv/core/signals/containers.py index 75689d6..5341fc5 100644 --- a/ipynbsrv/core/signals/containers.py +++ b/ipynbsrv/core/signals/containers.py @@ -72,9 +72,10 @@ def create_on_server(sender, container, **kwargs): if container.is_image_based(): cmd = container.image.command image = container.image.backend_pk - elif container.is_clone() and container.clone_of.is_image_based(): + elif container.is_clone(): clone_of = container.clone_of.backend_pk - cmd = container.clone_of.image.command + if container.clone_of.is_image_based(): + cmd = container.clone_of.image.command result = None try: @@ -145,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: diff --git a/lib/confs/nginx/ipynbsrv.conf b/lib/confs/nginx/ipynbsrv.conf index 45e1616..1379430 100644 --- a/lib/confs/nginx/ipynbsrv.conf +++ b/lib/confs/nginx/ipynbsrv.conf @@ -16,8 +16,8 @@ server { location / { include /usr/local/openresty/nginx/conf/uwsgi_params; - uwsgi_read_timeout 300s; - uwsgi_send_timeout 300s; + uwsgi_read_timeout 600s; + uwsgi_send_timeout 600s; uwsgi_param REQUEST_URI $uri$args; uwsgi_pass unix:/var/run/ipynbsrv/ipynbsrv.sock; } diff --git a/lib/confs/uwsgi/ipynbsrv.ini b/lib/confs/uwsgi/ipynbsrv.ini index fbed1e0..0161a6a 100644 --- a/lib/confs/uwsgi/ipynbsrv.ini +++ b/lib/confs/uwsgi/ipynbsrv.ini @@ -8,8 +8,8 @@ master=True vacuum=True max-requests=5000 processes=5 -harakiri=300 -chmod-socket = 660 -chown-socket = www-data:www-data +harakiri=600 +chmod-socket=660 +chown-socket=www-data:www-data pidfile=/var/run/ipynbsrv/ipynbsrv.pid uwsgi-socket=/var/run/ipynbsrv/ipynbsrv.sock