Hello Assaf,
Thanks very much for your contribution for this feature. I've opened
the following ticket to ensure it is incorporated into the distribution,
so you can "follow" the ticket if you want.
Hello,
I'd like to suggest a new feature - administrative lock which prevents
new jobs from starting.
Use case:
1. I need to stop my galaxy server (to upgrade, to add new tool, to
add new dbkey, etc).
2. I want to stop it in a friendly way, without killing running jobs,
but not allow new jobs to start.
3. Once all the running jobs complete (and new jobs are not started),
I can stop the server, fix it, and restart.
4. Restarting the server (and assuming jobs are tracked in the
database), all the held jobs are started normally.
Code changes:
1. new administrative method ( job_lock() in
./lib/galaxy/web/controller/admin.py )
2. new template ( ./templates/admin/job_lock.mako )
3. job lock code in lib/galaxy/jobs/schedulingpolicy/roundrobin.py
I'm still testing this patch, but comments are welcomed.
-gordon.
------------------------------------------------------------------------
------------------------------------------------------------------------
diff -r 46bd94b12a0c lib/galaxy/jobs/schedulingpolicy/roundrobin.py
--- a/lib/galaxy/jobs/schedulingpolicy/roundrobin.py Thu Jul 16 15:35:58 2009 -0400
+++ b/lib/galaxy/jobs/schedulingpolicy/roundrobin.py Thu Jul 23 13:08:33 2009 -0400
@@ -34,7 +34,13 @@
# locks for get and put methods
self.putlock = threading.Lock()
self.getlock = threading.Lock()
+ self.job_lock = False
log.info("RoundRobin policy: initialized ")
+
+ def set_job_lock ( self, newstate=True ):
+ self.getlock.acquire()
+ self.job_lock = newstate
+ self.getlock.release()
# Insert a job in the dict of queues
def put(self, job):
@@ -63,6 +69,9 @@
# get the next user/session in the dict
sessionid = self.__get_next_session()
if sessionid is not None :
+ if (self.job_lock):
+ log.info("RoundRobin queue: Job Lock active, returning:
Empty" )
+ raise Empty
log.debug("RoundRobin queue: retrieving job from job queue for
session = %d" % sessionid)
return self.__DOQ[sessionid].get()
else :
diff -r 46bd94b12a0c lib/galaxy/web/controllers/admin.py
--- a/lib/galaxy/web/controllers/admin.py Thu Jul 16 15:35:58 2009 -0400
+++ b/lib/galaxy/web/controllers/admin.py Thu Jul 23 13:08:33 2009 -0400
@@ -3,6 +3,7 @@
from galaxy import util, datatypes
from galaxy.web.base.controller import *
from galaxy.model.orm import *
+from galaxy.jobs.schedulingpolicy.roundrobin import UserRoundRobin
import sys
import logging
@@ -2059,6 +2060,31 @@
@web.expose
@web.require_admin
+ def job_lock ( self, trans, **kwd ):
+ params = util.Params( kwd )
+ newstate = params.get('joblockstate', '')
+ messagetype = 'done'
+ msg = ''
+ job_lock_active = False
+
+ #This is a bit ugly...
+ job_queue = self.app.job_manager.job_queue
+ if not job_queue.use_policy:
+ return trans.show_error_message ( message = 'Job lock requires
"User-Round-Robin" job scheduler.<br/>Please change
"job_scheduler_policy" settings in "universe_wsgi.ini"' )
+ sched_obj = self.app.job_manager.job_queue.squeue
+ if not isinstance(sched_obj, UserRoundRobin):
+ return trans.show_error_message ( message = 'Job lock requires
"User-Round-Robin" job scheduler.<br/>Please change
"job_scheduler_policy" settings in "universe_wsgi.ini"' )
+
+ if newstate == 'enabled':
+ msg = 'Job lock enabled'
+ sched_obj.set_job_lock(True)
+ elif newstate == 'disabled':
+ msg = 'Job lock disabled'
+ sched_obj.set_job_lock(False)
+ job_lock_active = sched_obj.job_lock
+ return trans.fill_template( '/admin/job_lock.mako',
job_lock_active=job_lock_active, msg=msg, messagetype=messagetype )
+ @web.expose
+ @web.require_admin
def jobs( self, trans, stop = [], stop_msg = None, cutoff = 180, **kwd ):
deleted = []
msg = None
diff -r 46bd94b12a0c templates/admin/index.mako
--- a/templates/admin/index.mako Thu Jul 16 15:35:58 2009 -0400
+++ b/templates/admin/index.mako Thu Jul 23 13:08:33 2009 -0400
@@ -101,6 +101,7 @@
<div class="toolTitle"><a href="${h.url_for(
controller='admin', action='reload_tool' )}"
target="galaxy_main">Reload a tool's configuration</a></div>
<div class="toolTitle"><a href="${h.url_for(
controller='admin', action='memdump' )}"
target="galaxy_main">Profile memory usage</a></div>
<div class="toolTitle"><a href="${h.url_for(
controller='admin', action='jobs' )}"
target="galaxy_main">Manage jobs</a></div>
+ <div class="toolTitle"><a href="${h.url_for(
controller='admin', action='job_lock' )}"
target="galaxy_main">Job Lock</a></div>
</div>
</div>
<div class="toolSectionPad"></div>
------------------------------------------------------------------------
_______________________________________________
galaxy-dev mailing list
galaxy-dev(a)bx.psu.edu
http://mail.bx.psu.edu/cgi-bin/mailman/listinfo/galaxy-dev