Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[master] Fix to scheduler for use of when and splay #56149

Merged
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion salt/utils/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,7 @@ def _handle_when(data, loop_interval):

if when < now - loop_interval and \
not data.get('_run', False) and \
not data.get('run', False) and \
not run and \
not data['_splay']:
data['_next_fire_time'] = None
data['_continue'] = True
Expand Down
16 changes: 15 additions & 1 deletion tests/integration/scheduler/test_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
import random
import time

import dateutil.parser as dateutil_parser
try:
import dateutil.parser as dateutil_parser
HAS_DATEUTIL_PARSER = True
except ImportError:
HAS_DATEUTIL_PARSER = False

import datetime

# Import Salt Testing libs
Expand Down Expand Up @@ -43,6 +48,7 @@
DEFAULT_CONFIG['cachedir'] = os.path.join(ROOT_DIR, 'cache')


@skipIf(HAS_DATEUTIL_PARSER is False, 'The \'dateutil.parser\' library is not available')
class SchedulerEvalTest(ModuleCase, SaltReturnAssertsMixin):
'''
Validate the pkg module
Expand Down Expand Up @@ -920,6 +926,7 @@ def test_eval_when_splay(self):
}
run_time1 = dateutil_parser.parse('11/29/2017 4:00pm')
run_time2 = run_time1 + datetime.timedelta(seconds=splay)
run_time3 = run_time2 + datetime.timedelta(seconds=1)

# Add the job to the scheduler
self.schedule.opts.update(job)
Expand All @@ -940,6 +947,13 @@ def test_eval_when_splay(self):
ret = self.schedule.job_status(job_name)
self.assertEqual(ret['_last_run'], run_time2)

# Evaluate at expected runtime3, should not run
# _next_fire_time should be None
self.schedule.eval(now=run_time3)
ret = self.schedule.job_status(job_name)
self.assertEqual(ret['_last_run'], run_time2)
self.assertEqual(ret['_next_fire_time'], None)

def test_eval_when_splay_in_past(self):
'''
verify that scheduled job runs
Expand Down