mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Rework code that handles individual jobs being disabled and scheduler being globally being disabled. Previously disabling the schedule would result in individual jobs being disabled when they were run through eval. This change does not change schedule items.
This commit is contained in:
parent
b61b30db7d
commit
be15a286b0
2 changed files with 10 additions and 24 deletions
|
@ -1596,22 +1596,10 @@ class Schedule(object):
|
|||
if '_continue' in data and data['_continue']:
|
||||
run = False
|
||||
|
||||
# If there is no job specific enabled available,
|
||||
# grab the global which defaults to True.
|
||||
if 'enabled' not in data:
|
||||
data['enabled'] = self.enabled
|
||||
|
||||
# If globally disabled, disable the job
|
||||
if not self.enabled:
|
||||
data['enabled'] = self.enabled
|
||||
data['_skip_reason'] = 'disabled'
|
||||
data['_skipped_time'] = now
|
||||
data['_skipped'] = True
|
||||
run = False
|
||||
|
||||
# Job is disabled, set run to False
|
||||
if 'enabled' in data and not data['enabled']:
|
||||
data['_enabled'] = False
|
||||
# If globally disabled or job
|
||||
# is diabled skip the job
|
||||
if not self.enabled or not data.get('enabled', True):
|
||||
log.trace('Job: %s is disabled', job_name)
|
||||
data['_skip_reason'] = 'disabled'
|
||||
data['_skipped_time'] = now
|
||||
data['_skipped'] = True
|
||||
|
@ -1624,14 +1612,6 @@ class Schedule(object):
|
|||
|
||||
try:
|
||||
if run:
|
||||
# Job is disabled, continue
|
||||
if 'enabled' in data and not data['enabled']:
|
||||
log.debug('Job: %s is disabled', job_name)
|
||||
data['_skip_reason'] = 'disabled'
|
||||
data['_skipped_time'] = now
|
||||
data['_skipped'] = True
|
||||
continue
|
||||
|
||||
if 'jid_include' not in data or data['jid_include']:
|
||||
data['jid_include'] = True
|
||||
log.debug('schedule: Job %s was scheduled with jid_include, '
|
||||
|
|
|
@ -506,6 +506,9 @@ class SchedulerEvalTest(ModuleCase, SaltReturnAssertsMixin):
|
|||
self.assertNotIn('_last_run', ret)
|
||||
self.assertEqual(ret['_skip_reason'], 'disabled')
|
||||
|
||||
# Ensure job data still matches
|
||||
self.assertEqual(ret, job['schedule'][job_name])
|
||||
|
||||
def test_eval_global_disabled_job_enabled(self):
|
||||
'''
|
||||
verify that scheduled job does not run
|
||||
|
@ -532,6 +535,9 @@ class SchedulerEvalTest(ModuleCase, SaltReturnAssertsMixin):
|
|||
self.assertNotIn('_last_run', ret)
|
||||
self.assertEqual(ret['_skip_reason'], 'disabled')
|
||||
|
||||
# Ensure job is still enabled
|
||||
self.assertEqual(ret['enabled'], True)
|
||||
|
||||
def test_eval_run_on_start(self):
|
||||
'''
|
||||
verify that scheduled job is run when minion starts
|
||||
|
|
Loading…
Add table
Reference in a new issue