Skip to content

Commit e8acfdc

Browse files
Merge pull request #201 from Dany9966/cron-lastrun-fix
Remove last run check for replica cron jobs
2 parents 30cfab2 + 3c432a9 commit e8acfdc

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

coriolis/cron/cron.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ def __init__(self, name, description, schedule, enabled,
7373
raise exception.CoriolisException(
7474
"Invalid expires")
7575
self._expires = expires
76-
self._last_run = None
7776

7877
def _compare(self, pairs):
7978
# we don't support the full cron syntax. Either exact matches
@@ -104,11 +103,7 @@ def should_run(self, dt):
104103
if self._enabled is False:
105104
LOG.debug('Job %s is not enabled', self.name)
106105
return False
107-
if self._last_run:
108-
if (dt - self._last_run).total_seconds() < 60:
109-
LOG.debug('Job %s has last run in less than a minute ago. '
110-
'Skipping.', self.name)
111-
return False
106+
112107
fields = ('year', 'month', 'dom', 'hour',
113108
'minute', 'second', 'dow')
114109
dt_fields = dict(zip(fields, dt.timetuple()))
@@ -122,7 +117,7 @@ def _send_status(self, queue, status):
122117
return
123118
queue.put(status)
124119

125-
def start(self, dt, status_queue=None):
120+
def start(self, status_queue=None):
126121
result = None
127122
exc_info = None
128123
try:
@@ -142,8 +137,7 @@ def start(self, dt, status_queue=None):
142137
{"result": result,
143138
"description": self._description,
144139
"name": self.name,
145-
"error_info": exc_info,
146-
"last_run": dt})
140+
"error_info": exc_info})
147141

148142

149143
class Cron(object):
@@ -194,7 +188,7 @@ def _check_jobs(self):
194188
jobs[job].schedule)
195189
if jobs[job].should_run(now):
196190
LOG.debug("Spawning job %s" % job)
197-
eventlet.spawn(jobs[job].start, now, self._queue)
191+
eventlet.spawn(jobs[job].start, self._queue)
198192
spawned += 1
199193

200194
done = timeutils.utcnow()
@@ -211,13 +205,9 @@ def _loop(self):
211205
def _result_loop(self):
212206
while True:
213207
job_info = self._queue.get()
214-
name = job_info["name"]
215208
result = job_info["result"]
216209
error = job_info["error_info"]
217-
last_run = job_info["last_run"]
218210
desc = job_info["description"]
219-
with self._semaphore:
220-
self._jobs[name]._last_run = last_run
221211
# TODO(gsamfira): send this to the controller and update
222212
# the logs table...or do something much more meaningful
223213
if error:

0 commit comments

Comments
 (0)