diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2014-02-24 18:01:53 +0000 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2014-02-24 18:01:53 +0000 |
commit | 86cba38e711a84641ac14fc75dfbe67ddcb3a6d3 (patch) | |
tree | 84d4b52c5a18f62561a1d71422d9ad8fd6d12335 | |
parent | c1aa70e228c72173f8640326ba337c74b4ca30b3 (diff) | |
download | lorry-controller-liw/daemonise-read-config.tar.gz |
Only schedule jobs when running_queue is set to trueliw/daemonise-read-config
-rwxr-xr-x | lorry-controller-webapp | 24 | ||||
-rw-r--r-- | yarns.webapp/040-running-jobs.yarn | 11 |
2 files changed, 22 insertions, 13 deletions
diff --git a/lorry-controller-webapp b/lorry-controller-webapp index 468f941..8543899 100755 --- a/lorry-controller-webapp +++ b/lorry-controller-webapp @@ -610,17 +610,19 @@ class GiveMeJob(LorryControllerRoute): def run(self, **kwargs): logging.debug('%s %s called', self.http_method, self.path) - with self.statedb.transaction(): - lorry_infos = self.statedb.get_all_lorries_info() - for lorry_info in lorry_infos: - if lorry_info['running_job'] is None: - path = lorry_info['path'] - running_job = self.statedb.get_next_job_id() - self.statedb.set_running_job(path, running_job) - return { - 'job_id': running_job, - 'path': path, - } + + if self.statedb.get_running_queue(): + with self.statedb.transaction(): + lorry_infos = self.statedb.get_all_lorries_info() + for lorry_info in lorry_infos: + if lorry_info['running_job'] is None: + path = lorry_info['path'] + running_job = self.statedb.get_next_job_id() + self.statedb.set_running_job(path, running_job) + return { + 'job_id': running_job, + 'path': path, + } return { 'job_id': None } diff --git a/yarns.webapp/040-running-jobs.yarn b/yarns.webapp/040-running-jobs.yarn index 2c4a076..7d5a319 100644 --- a/yarns.webapp/040-running-jobs.yarn +++ b/yarns.webapp/040-running-jobs.yarn @@ -22,13 +22,19 @@ To start with, with an empty run-queue, nothing should be scheduled. WHEN admin makes request GET /1.0/list-running-jobs THEN response has running_jobs set to [] -Add a Lorry spec to the run-queue, and request a job. We should get -that job now. +Add a Lorry spec to the run-queue, and request a job. We still +shouldn't get a job, since the queue isn't set to run yet. GIVEN Lorry file CONFGIT/foo.lorry with {"foo":{"type":"git","url":"git://foo"}} WHEN admin makes request GET /1.0/read-configuration AND admin makes request GET /1.0/give-me-job + THEN response has job_id set to null + +Enable the queue, and off we go. + + WHEN admin makes request GET /1.0/start-queue + AND admin makes request GET /1.0/give-me-job THEN response has job_id set to 1 AND response has path set to "upstream/foo" @@ -67,6 +73,7 @@ we did for the successful job scenario. AND a running WEBAPP AND Lorry file CONFGIT/foo.lorry with {"foo":{"type":"git","url":"git://foo"}} WHEN admin makes request GET /1.0/read-configuration + AND admin makes request GET /1.0/start-queue AND admin makes request GET /1.0/give-me-job THEN response has job_id set to 1 AND response has path set to "upstream/foo" |