Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions coriolis/cron/cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def __init__(self, name, description, schedule, enabled,
raise exception.CoriolisException(
"Invalid expires")
self._expires = expires
self._last_run = None

def _compare(self, pairs):
# we don't support the full cron syntax. Either exact matches
Expand Down Expand Up @@ -104,11 +103,7 @@ def should_run(self, dt):
if self._enabled is False:
LOG.debug('Job %s is not enabled', self.name)
return False
if self._last_run:
if (dt - self._last_run).total_seconds() < 60:
LOG.debug('Job %s has last run in less than a minute ago. '
'Skipping.', self.name)
return False

fields = ('year', 'month', 'dom', 'hour',
'minute', 'second', 'dow')
dt_fields = dict(zip(fields, dt.timetuple()))
Expand All @@ -122,7 +117,7 @@ def _send_status(self, queue, status):
return
queue.put(status)

def start(self, dt, status_queue=None):
def start(self, status_queue=None):
result = None
exc_info = None
try:
Expand All @@ -142,8 +137,7 @@ def start(self, dt, status_queue=None):
{"result": result,
"description": self._description,
"name": self.name,
"error_info": exc_info,
"last_run": dt})
"error_info": exc_info})


class Cron(object):
Expand Down Expand Up @@ -194,7 +188,7 @@ def _check_jobs(self):
jobs[job].schedule)
if jobs[job].should_run(now):
LOG.debug("Spawning job %s" % job)
eventlet.spawn(jobs[job].start, now, self._queue)
eventlet.spawn(jobs[job].start, self._queue)
spawned += 1

done = timeutils.utcnow()
Expand All @@ -211,13 +205,9 @@ def _loop(self):
def _result_loop(self):
while True:
job_info = self._queue.get()
name = job_info["name"]
result = job_info["result"]
error = job_info["error_info"]
last_run = job_info["last_run"]
desc = job_info["description"]
with self._semaphore:
self._jobs[name]._last_run = last_run
# TODO(gsamfira): send this to the controller and update
# the logs table...or do something much more meaningful
if error:
Expand Down