From cc89acf00f5ecf1e8da7abac045070e6b87777e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20Ka=CC=88ser?= Date: Tue, 11 Aug 2015 16:15:03 +0200 Subject: [PATCH 1/5] only if image based --- ipynbsrv/core/signals/containers.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ipynbsrv/core/signals/containers.py b/ipynbsrv/core/signals/containers.py index 75689d6..8350324 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: From 6127adcd6977f356bb7c6667148d39187d7db36f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20Ka=CC=88ser?= Date: Tue, 11 Aug 2015 17:01:27 +0200 Subject: [PATCH 2/5] increase timeouts; don't allow container creation from internal images --- ipynbsrv/core/models.py | 4 ++++ lib/confs/nginx/ipynbsrv.conf | 4 ++-- lib/confs/uwsgi/ipynbsrv.ini | 6 +++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ipynbsrv/core/models.py b/ipynbsrv/core/models.py index 6dea440..250093a 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/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 From a645b0659a5fb143a12371defe72ea41dcb526e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20Ka=CC=88ser?= Date: Tue, 11 Aug 2015 17:11:38 +0200 Subject: [PATCH 3/5] ensure image is not removed before the container -> leads to problems --- ipynbsrv/core/signals/container_images.py | 14 -------------- ipynbsrv/core/signals/containers.py | 4 ++++ 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/ipynbsrv/core/signals/container_images.py b/ipynbsrv/core/signals/container_images.py index 16dcc8b..690779e 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): """ diff --git a/ipynbsrv/core/signals/containers.py b/ipynbsrv/core/signals/containers.py index 8350324..a6329fe 100644 --- a/ipynbsrv/core/signals/containers.py +++ b/ipynbsrv/core/signals/containers.py @@ -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: From 465f645aaa36c9ebe5fdd0ce0372f5b939859c4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20Ka=CC=88ser?= Date: Tue, 11 Aug 2015 17:20:14 +0200 Subject: [PATCH 4/5] ignore cleanup for the moment --- ipynbsrv/core/signals/containers.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ipynbsrv/core/signals/containers.py b/ipynbsrv/core/signals/containers.py index a6329fe..5341fc5 100644 --- a/ipynbsrv/core/signals/containers.py +++ b/ipynbsrv/core/signals/containers.py @@ -147,9 +147,9 @@ def delete_on_server(sender, container, **kwargs): 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() + # 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: From 90fdcee788221087569e6d0bf75e1221e0f4b6dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20Ka=CC=88ser?= Date: Tue, 11 Aug 2015 17:38:15 +0200 Subject: [PATCH 5/5] last resort --- ipynbsrv/core/signals/container_images.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ipynbsrv/core/signals/container_images.py b/ipynbsrv/core/signals/container_images.py index 690779e..9a488fe 100644 --- a/ipynbsrv/core/signals/container_images.py +++ b/ipynbsrv/core/signals/container_images.py @@ -45,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)