fixing merge conflict

This commit is contained in:
Gareth J. Greenaway 2018-01-17 12:35:56 -08:00
parent 3d2d8c986f
commit 3c2f5d3396
No known key found for this signature in database
GPG Key ID: 10B62F8A7CAD7A41
3 changed files with 35 additions and 31 deletions

View File

@ -953,7 +953,7 @@ class Schedule(object):
if when < now - self.opts['loop_interval'] and \
not data.get('_run', False) and \
not run and \
not data.get('run', False) and \
not data['_splay']:
data['_next_fire_time'] = None
data['_continue'] = True
@ -1183,9 +1183,15 @@ class Schedule(object):
'skip_function',
'skip_during_range']
for job, data in six.iteritems(schedule):
# Clear these out between runs
for item in ['_continue',
'_error',
'_skip_reason']:
if item in data:
del data[item]
run = False
if job in _hidden and not data:
if job in _hidden:
continue
if not isinstance(data, dict):
@ -1298,6 +1304,7 @@ class Schedule(object):
# An error occurred so we bail out
if '_error' in data and data['_error']:
log.debug('Sommething went wrong')
continue
seconds = data['_next_fire_time'] - now
@ -1403,22 +1410,6 @@ class Schedule(object):
miss_msg = ' (runtime missed ' \
'by {0} seconds)'.format(abs(seconds))
if 'jid_include' not in data or data['jid_include']:
data['jid_include'] = True
log.debug('schedule: This job was scheduled with jid_include, '
'adding to cache (jid_include defaults to True)')
if 'maxrunning' in data:
log.debug(
'schedule: This job was scheduled with a max number '
'of %s', data['maxrunning']
)
else:
log.info(
'schedule: maxrunning parameter was not specified '
'for job %s, defaulting to 1.', job
)
data['maxrunning'] = 1
multiprocessing_enabled = self.opts.get('multiprocessing', True)
if salt.utils.platform.is_windows():
@ -1430,10 +1421,20 @@ class Schedule(object):
returners = self.returners
self.returners = {}
try:
if not run:
log.info('Not running scheduled job: {0}'.format(job))
else:
log.info('Running scheduled job: {0}{1}'.format(job, miss_msg))
if run:
if 'jid_include' not in data or data['jid_include']:
data['jid_include'] = True
log.debug('schedule: This job was scheduled with jid_include, '
'adding to cache (jid_include defaults to True)')
if 'maxrunning' in data:
log.debug('schedule: This job was scheduled with a max '
'number of %s', data['maxrunning'])
else:
log.info('schedule: maxrunning parameter was not specified for '
'job %s, defaulting to 1.', job)
data['maxrunning'] = 1
log.info('Running scheduled job: %s%s', job, miss_msg)
if multiprocessing_enabled:
thread_cls = salt.utils.process.SignalHandlingMultiprocessingProcess
@ -1452,12 +1453,13 @@ class Schedule(object):
if multiprocessing_enabled:
proc.join()
finally:
if '_seconds' in data:
data['_next_fire_time'] = now + data['_seconds']
# Only set _last_run if the job ran
if run:
data['_last_run'] = now
data['_splay'] = None
if '_seconds' in data:
data['_next_fire_time'] = now + data['_seconds']
data['_splay'] = None
if salt.utils.platform.is_windows():
# Restore our function references.
self.functions = functions

View File

@ -326,15 +326,16 @@ class SchedulerEvalTest(ModuleCase, SaltReturnAssertsMixin):
verify that scheduled job does not run
and returns the right error
'''
run_time = int(time.mktime(dateutil_parser.parse('11/29/2017 4:00pm').timetuple()))
job = {
'schedule': {
'job1': {
'function': 'test.ping',
'when': '11/29/2017 13:00pm',
'when': '13/29/2017 1:00pm',
}
}
}
run_time = int(time.mktime(dateutil_parser.parse('11/29/2017 4:00pm').timetuple()))
# Add the job to the scheduler
self.schedule.opts.update(job)

View File

@ -110,12 +110,14 @@ class SchedulerSkipTest(ModuleCase, SaltReturnAssertsMixin):
'''
verify that scheduled job is not not and returns the right error string
'''
run_time = int(time.mktime(dateutil_parser.parse('11/29/2017 2:30pm').timetuple()))
job1 = {
'schedule': {
'job1': {
'function': 'test.ping',
'hours': '1',
'_next_fire_time': 1511994600,
'_next_fire_time': run_time,
'skip_during_range': {
'start': '25pm',
'end': '3pm'
@ -129,7 +131,7 @@ class SchedulerSkipTest(ModuleCase, SaltReturnAssertsMixin):
'job2': {
'function': 'test.ping',
'hours': '1',
'_next_fire_time': 1511994600,
'_next_fire_time': run_time,
'skip_during_range': {
'start': '2pm',
'end': '25pm'
@ -138,8 +140,6 @@ class SchedulerSkipTest(ModuleCase, SaltReturnAssertsMixin):
}
}
run_time = int(time.mktime(dateutil_parser.parse('11/29/2017 2:30pm').timetuple()))
# Add job1 to schedule
self.schedule.opts.update(job1)
@ -151,6 +151,7 @@ class SchedulerSkipTest(ModuleCase, SaltReturnAssertsMixin):
_expected = ('Invalid date string for start in ',
'skip_during_range. Ignoring ',
'job %s.', 'job1')
log.debug('=== ret %s ===', ret)
self.assertEqual(ret['_error'], _expected)
# Clear out schedule