mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #42107 from vutny/2017.7-fix-jobs-scheduled-with-whens
[2017.7] Fix scheduled jobs if `when` parameter is a list
This commit is contained in:
commit
4f044999fa
1 changed files with 13 additions and 6 deletions
|
@ -1130,21 +1130,28 @@ class Schedule(object):
|
|||
log.error('Invalid date string {0}. '
|
||||
'Ignoring job {1}.'.format(i, job))
|
||||
continue
|
||||
when = int(time.mktime(when__.timetuple()))
|
||||
if when >= now:
|
||||
_when.append(when)
|
||||
_when.append(int(time.mktime(when__.timetuple())))
|
||||
|
||||
if data['_splay']:
|
||||
_when.append(data['_splay'])
|
||||
|
||||
# Sort the list of "whens" from earlier to later schedules
|
||||
_when.sort()
|
||||
|
||||
for i in _when:
|
||||
if i < now and len(_when) > 1:
|
||||
# Remove all missed schedules except the latest one.
|
||||
# We need it to detect if it was triggered previously.
|
||||
_when.remove(i)
|
||||
|
||||
if _when:
|
||||
# Grab the first element
|
||||
# which is the next run time
|
||||
# Grab the first element, which is the next run time or
|
||||
# last scheduled time in the past.
|
||||
when = _when[0]
|
||||
|
||||
if '_run' not in data:
|
||||
data['_run'] = True
|
||||
# Prevent run of jobs from the past
|
||||
data['_run'] = bool(when >= now)
|
||||
|
||||
if not data['_next_fire_time']:
|
||||
data['_next_fire_time'] = when
|
||||
|
|
Loading…
Add table
Reference in a new issue