Merge pull request #49019 from garethgreenaway/47695_fixing_scheduler_bug_when_enabled_is_present

[2018.3] Fix to scheduler when global enabled key is present
This commit is contained in:
Nicole Thomas 2018-08-09 09:06:25 -04:00 committed by GitHub
commit d353c02a8c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 3 deletions

View file

@ -843,15 +843,15 @@ class Schedule(object):
'skip_during_range']
for job, data in six.iteritems(schedule):
if job in _hidden:
continue
# Clear out _skip_reason from previous runs
if '_skip_reason' in data:
del data['_skip_reason']
run = False
if job in _hidden:
continue
if not isinstance(data, dict):
log.error(
'Scheduled job "%s" should have a dict value, not %s',

View file

@ -397,3 +397,34 @@ class SchedulerEvalTest(ModuleCase, SaltReturnAssertsMixin):
self.schedule.eval(now=run_time)
ret = self.schedule.job_status('job1')
self.assertEqual(ret['_last_run'], run_time)
def test_eval_enabled(self):
'''
verify that scheduled job runs
when the enabled key is in place
https://github.com/saltstack/salt/issues/47695
'''
job = {
'schedule': {
'enabled': True,
'job1': {
'function': 'test.ping',
'when': '11/29/2017 4:00pm',
}
}
}
run_time2 = dateutil_parser.parse('11/29/2017 4:00pm')
run_time1 = run_time2 - datetime.timedelta(seconds=1)
# Add the job to the scheduler
self.schedule.opts.update(job)
# Evaluate 1 second before the run time
self.schedule.eval(now=run_time1)
ret = self.schedule.job_status('job1')
self.assertNotIn('_last_run', ret)
# Evaluate 1 second at the run time
self.schedule.eval(now=run_time2)
ret = self.schedule.job_status('job1')
self.assertEqual(ret['_last_run'], run_time2)