Merge pull request #17187 from saltstack/revert-17120-issue_17000

Revert "Move the scheduler to its own process"
This commit is contained in:
Colton Myers 2014-11-05 11:31:59 -07:00
commit b142a47109

View File

@ -89,42 +89,6 @@ class SMaster(object):
return salt.daemons.masterapi.access_keys(self.opts)
class Scheduler(multiprocessing.Process):
'''
The master scheduler process.
This runs in its own process so that it can have a fully
independent loop from the Maintenance process.
'''
def __init__(self, opts):
super(Scheduler, self).__init__()
self.opts = opts
# Init Scheduler
self.schedule = salt.utils.schedule.Schedule(self.opts,
salt.loader.runner(self.opts),
returners=salt.loader.returners(self.opts, {}))
def run(self):
salt.utils.appendproctitle('Scheduler')
while True:
self.handle_schedule()
try:
time.sleep(self.schedule.loop_interval)
except KeyboardInterrupt:
break
def handle_schedule(self):
'''
Evaluate the scheduler
'''
try:
self.schedule.eval()
except Exception as exc:
log.error(
'Exception {0} occurred in scheduled job'.format(exc)
)
class Maintenance(multiprocessing.Process):
'''
A generalized maintenence process which performances maintenence
@ -140,7 +104,14 @@ class Maintenance(multiprocessing.Process):
self.opts = opts
# Init fileserver manager
self.fileserver = salt.fileserver.Fileserver(self.opts)
# Matcher
# Load Runners
self.runners = salt.loader.runner(self.opts)
# Load Returners
self.returners = salt.loader.returners(self.opts, {})
# Init Scheduler
self.schedule = salt.utils.schedule.Schedule(self.opts,
self.runners,
returners=self.returners)
self.ckminions = salt.utils.minions.CkMinions(self.opts)
# Make Event bus for firing
self.event = salt.utils.event.MasterEvent(self.opts['sock_dir'])
@ -176,6 +147,7 @@ class Maintenance(multiprocessing.Process):
salt.daemons.masterapi.clean_expired_tokens(self.opts)
self.handle_search(now, last)
self.handle_pillargit()
self.handle_schedule()
self.handle_presence(old_present)
self.handle_key_rotate(now)
salt.daemons.masterapi.fileserver_update(self.fileserver)
@ -222,6 +194,21 @@ class Maintenance(multiprocessing.Process):
log.error('Exception {0} occurred in file server update '
'for git_pillar module.'.format(exc))
def handle_schedule(self):
'''
Evaluate the scheduler
'''
try:
self.schedule.eval()
# Check if scheduler requires lower loop interval than
# the loop_interval setting
if self.schedule.loop_interval < self.loop_interval:
self.loop_interval = self.schedule.loop_interval
except Exception as exc:
log.error(
'Exception {0} occurred in scheduled job'.format(exc)
)
def handle_presence(self, old_present):
'''
Fire presence events if enabled
@ -352,8 +339,6 @@ class Master(SMaster):
process_manager = salt.utils.process.ProcessManager()
log.info('Creating master maintenance process')
process_manager.add_process(Maintenance, args=(self.opts,))
log.info('Creating master scheduler process')
process_manager.add_process(Scheduler, args=(self.opts,))
log.info('Creating master publisher process')
process_manager.add_process(Publisher, args=(self.opts,))
log.info('Creating master event publisher process')