mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Additional fixes.
Better detection of schedule init, handle failed beacons and remove unnedeed debug statements.
This commit is contained in:
parent
8a4969b730
commit
049a3dbbbc
1 changed files with 22 additions and 11 deletions
|
@ -334,7 +334,11 @@ class MinionBase(object):
|
|||
@staticmethod
|
||||
def process_schedule(minion, loop_interval):
|
||||
try:
|
||||
minion.schedule.eval()
|
||||
if hasattr(minion, 'schedule'):
|
||||
minion.schedule.eval()
|
||||
else:
|
||||
log.error('Minion scheduler not initialized. Scheduled jobs will not be run.')
|
||||
return
|
||||
# Check if scheduler requires lower loop interval than
|
||||
# the loop_interval setting
|
||||
if minion.schedule.loop_interval < loop_interval:
|
||||
|
@ -713,16 +717,18 @@ class Minion(MinionBase):
|
|||
'''
|
||||
Block until we are connected to a master
|
||||
'''
|
||||
log.debug("sync_connect_master")
|
||||
self._connect_master_future = self.connect_master()
|
||||
# finish connecting to master
|
||||
self._connect_master_future.add_done_callback(lambda f: self.io_loop.stop())
|
||||
self.io_loop.start()
|
||||
try:
|
||||
self.io_loop.start()
|
||||
except KeyboardInterrupt:
|
||||
self.destroy()
|
||||
# I made the following 3 line oddity to preserve traceback.
|
||||
# Please read PR #23978 before changing, hopefully avoiding regressions.
|
||||
# Good luck, we're all counting on you. Thanks.
|
||||
future_exception = self._connect_master_future.exc_info()
|
||||
if future_exception:
|
||||
if future_exception and future_exception[0] is not salt.exceptions.SaltClientError:
|
||||
raise six.reraise(*future_exception)
|
||||
|
||||
@tornado.gen.coroutine
|
||||
|
@ -1648,9 +1654,9 @@ class Minion(MinionBase):
|
|||
|
||||
if start:
|
||||
self.sync_connect_master()
|
||||
|
||||
self._fire_master_minion_start()
|
||||
log.info('Minion is ready to receive requests!')
|
||||
if hasattr(self, 'connected') and self.connected:
|
||||
self._fire_master_minion_start()
|
||||
log.info('Minion is ready to receive requests!')
|
||||
|
||||
# Make sure to gracefully handle SIGUSR1
|
||||
enable_sigusr1_handler()
|
||||
|
@ -1697,30 +1703,35 @@ class Minion(MinionBase):
|
|||
|
||||
def handle_beacons():
|
||||
# Process Beacons
|
||||
beacons = None
|
||||
try:
|
||||
beacons = self.process_beacons(self.functions)
|
||||
except Exception:
|
||||
log.critical('The beacon errored: ', exc_info=True)
|
||||
if beacons:
|
||||
self._fire_master(events=beacons)
|
||||
self.periodic_callbacks['beacons'] = tornado.ioloop.PeriodicCallback(handle_beacons, loop_interval * 1000, io_loop=self.io_loop)
|
||||
self.periodic_callbacks['beacons'] = tornado.ioloop.PeriodicCallback(handle_beacons, loop_interval * 1000, io_loop=self.io_loop)
|
||||
|
||||
# TODO: actually listen to the return and change period
|
||||
def handle_schedule():
|
||||
self.process_schedule(self, loop_interval)
|
||||
self.periodic_callbacks['schedule'] = tornado.ioloop.PeriodicCallback(handle_schedule, 1000, io_loop=self.io_loop)
|
||||
if hasattr(self, 'schedule'):
|
||||
self.periodic_callbacks['schedule'] = tornado.ioloop.PeriodicCallback(handle_schedule, 1000, io_loop=self.io_loop)
|
||||
|
||||
# start all the other callbacks
|
||||
for periodic_cb in six.itervalues(self.periodic_callbacks):
|
||||
periodic_cb.start()
|
||||
|
||||
# add handler to subscriber
|
||||
self.pub_channel.on_recv(self._handle_payload)
|
||||
if hasattr(self, 'pub_channel'):
|
||||
self.pub_channel.on_recv(self._handle_payload)
|
||||
else:
|
||||
log.error('No connection to master found. Scheduled jobs will not run.')
|
||||
|
||||
if start:
|
||||
try:
|
||||
self.io_loop.start()
|
||||
except KeyboardInterrupt:
|
||||
except (KeyboardInterrupt, RuntimeError): # A RuntimeError can be re-raised by Tornado on shutdown
|
||||
self.destroy()
|
||||
|
||||
def _handle_payload(self, payload):
|
||||
|
|
Loading…
Add table
Reference in a new issue