mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Merge pull request #10313 from s0undt3ch/hotfix/minion-hang-on-join
Stop the Jenkins aborted buidls
This commit is contained in:
commit
010d4231f8
@ -520,6 +520,7 @@ class Minion(object):
|
||||
'''
|
||||
Pass in the options dict
|
||||
'''
|
||||
self._running = None
|
||||
|
||||
# Warn if ZMQ < 3.2
|
||||
if HAS_ZMQ and (not(hasattr(zmq, 'zmq_version_info')) or
|
||||
@ -1073,6 +1074,7 @@ class Minion(object):
|
||||
Python does not handle the SIGTERM cleanly, if it is signaled exit
|
||||
the minion process cleanly
|
||||
'''
|
||||
self._running = False
|
||||
exit(0)
|
||||
|
||||
# Main Minion Tune In
|
||||
@ -1081,6 +1083,21 @@ class Minion(object):
|
||||
Lock onto the publisher. This is the main event loop for the minion
|
||||
:rtype : None
|
||||
'''
|
||||
if self._running is None:
|
||||
self._running = True
|
||||
elif self._running is False:
|
||||
log.error(
|
||||
'This {0} was scheduled to stop. Not running '
|
||||
'{0}.tune_in()'.format(self.__class__.__name__)
|
||||
)
|
||||
return
|
||||
elif self._running is True:
|
||||
log.error(
|
||||
'This {0} is already running. Not running '
|
||||
'{0}.tune_in()'.format(self.__class__.__name__)
|
||||
)
|
||||
return
|
||||
|
||||
try:
|
||||
log.info(
|
||||
'{0} is starting as user \'{1}\''.format(
|
||||
@ -1098,7 +1115,10 @@ class Minion(object):
|
||||
),
|
||||
exc_info=err
|
||||
)
|
||||
|
||||
# Properly exit if a SIGTERM is signalled
|
||||
signal.signal(signal.SIGTERM, self.clean_die)
|
||||
|
||||
log.debug('Minion {0!r} trying to tune in'.format(self.opts['id']))
|
||||
self.context = zmq.Context()
|
||||
|
||||
@ -1281,7 +1301,7 @@ class Minion(object):
|
||||
exc)
|
||||
)
|
||||
|
||||
while True:
|
||||
while self._running is True:
|
||||
try:
|
||||
self.schedule.eval()
|
||||
# Check if scheduler requires lower loop interval than
|
||||
@ -1327,13 +1347,13 @@ class Minion(object):
|
||||
except Exception:
|
||||
log.debug('Exception while handling events', exc_info=True)
|
||||
|
||||
except zmq.ZMQError as e:
|
||||
except zmq.ZMQError as exc:
|
||||
# The interrupt caused by python handling the
|
||||
# SIGCHLD. Throws this error with errno == EINTR.
|
||||
# Nothing to recieve on the zmq socket throws this error
|
||||
# with EAGAIN.
|
||||
# Both are sage to ignore
|
||||
if e.errno != errno.EAGAIN and e.errno != errno.EINTR:
|
||||
# Both are safe to ignore
|
||||
if exc.errno != errno.EAGAIN and exc.errno != errno.EINTR:
|
||||
log.critical('Unexpected ZMQError while polling minion',
|
||||
exc_info=True)
|
||||
continue
|
||||
@ -1393,7 +1413,7 @@ class Minion(object):
|
||||
tagify([self.opts['id'], 'start'], 'minion'),
|
||||
)
|
||||
loop_interval = int(self.opts['loop_interval'])
|
||||
while True:
|
||||
while self._running is True:
|
||||
try:
|
||||
socks = dict(self.poller.poll(
|
||||
loop_interval * 1000)
|
||||
@ -1416,6 +1436,7 @@ class Minion(object):
|
||||
'''
|
||||
Tear down the minion
|
||||
'''
|
||||
self._running = False
|
||||
if hasattr(self, 'poller'):
|
||||
if isinstance(self.poller.sockets, dict):
|
||||
for socket in self.poller.sockets.keys():
|
||||
|
@ -361,17 +361,15 @@ class TestDaemon(object):
|
||||
'''
|
||||
Kill the minion and master processes
|
||||
'''
|
||||
import integration
|
||||
integration.SYNDIC = None
|
||||
self.sub_minion_process.terminate()
|
||||
salt.master.clean_proc(self.sub_minion_process, wait_for_kill=50)
|
||||
self.sub_minion_process.join()
|
||||
self.minion_process.terminate()
|
||||
salt.master.clean_proc(self.minion_process, wait_for_kill=50)
|
||||
self.minion_process.join()
|
||||
self.master_process.terminate()
|
||||
salt.master.clean_proc(self.master_process, wait_for_kill=50)
|
||||
self.master_process.join()
|
||||
self.syndic_process.terminate()
|
||||
salt.master.clean_proc(self.syndic_process, wait_for_kill=50)
|
||||
self.syndic_process.join()
|
||||
self.smaster_process.terminate()
|
||||
salt.master.clean_proc(self.smaster_process, wait_for_kill=50)
|
||||
self.smaster_process.join()
|
||||
self._exit_mockbin()
|
||||
self._clean()
|
||||
|
Loading…
Reference in New Issue
Block a user