Skip to content

Commit

Permalink
Merge branch 'master' of git.rackster.ch:ipynbsrv/ipynbsrv
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Glatthard committed Aug 11, 2015
2 parents 5674d32 + 90fdcee commit eb57367
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 23 deletions.
4 changes: 4 additions & 0 deletions ipynbsrv/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
19 changes: 3 additions & 16 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 All @@ -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)
Expand Down
9 changes: 7 additions & 2 deletions ipynbsrv/core/signals/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions lib/confs/nginx/ipynbsrv.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/confs/uwsgi/ipynbsrv.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit eb57367

Please sign in to comment.