Commit 46975d57 authored by BAIRE Anthony's avatar BAIRE Anthony
Browse files

support triggering sandbox actions in the controller

parent de3fd5f2
......@@ -1935,7 +1935,7 @@ class DockerController:
if item_type == b"job":
self.job_manager.process(item_id)
elif item_type == b"sandbox":
elif item_type == b"webapp":
self.sandbox_manager.process(item_id)
else:
log.warning("ignored notification for unknown item %r", msg)
......
......@@ -116,6 +116,8 @@ def notify_controller(obj):
if isinstance(obj, Job):
conn.publish(REDIS_CHANNEL_CONTROLLER, REDIS_MESSAGE_JOB_UPDATED % obj.id)
elif isinstance(obj, models.Webapp):
conn.publish(REDIS_CHANNEL_CONTROLLER, REDIS_MESSAGE_WEBAPP_UPDATED % obj.id)
else:
raise TypeError(obj)
......@@ -4,7 +4,7 @@ from django.db import transaction
from django.db.models.signals import post_save
from .helpers import notify_controller
from .models import Job
from .models import Job, Webapp
import logging
......@@ -20,7 +20,15 @@ def job_post_save(instance, **kw):
if instance.state in (Job.WAITING, Job.ABORTING):
transaction.on_commit(lambda: notify_controller(instance))
def webapp_post_save(instance, **kw):
# the controller needs to be notified if the sandbox is in
# STARTING/STOPPING states
#
if instance.sandbox_state in (Webapp.STARTING, Webapp.STOPPING):
transaction.on_commit(lambda: notify_controller(instance))
post_save.connect(job_post_save, sender=Job)
post_save.connect(webapp_post_save, sender=Webapp)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment