Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues/30643 merge forward fixes #31525

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 14 additions & 5 deletions salt/minion.py
Expand Up @@ -1593,18 +1593,25 @@ def handle_event(self, package):
if self.opts['master_type'] == 'failover':
log.info('Trying to tune in to next master from master-list')

if hasattr(self, 'pub_channel'):
self.pub_channel.on_recv(None)
if hasattr(self.pub_channel, 'close'):
self.pub_channel.close()
del self.pub_channel

# if eval_master finds a new master for us, self.connected
# will be True again on successful master authentication
self.opts['master'] = self.eval_master(opts=self.opts,
failed=True)
master, self.pub_channel = yield self.eval_master(
opts=self.opts,
failed=True)
if self.connected:
self.opts['master'] = master

# re-init the subsystems to work with the new master
log.info('Re-initialising subsystems for new '
'master {0}'.format(self.opts['master']))
del self.pub_channel
self._connect_master_future = self.connect_master()
self.block_until_connected() # TODO: remove
self.functions, self.returners, self.function_errors = self._load_modules()
self.pub_channel.on_recv(self._handle_payload)
self._fire_master_minion_start()
log.info('Minion is ready to receive requests!')

Expand Down Expand Up @@ -1813,6 +1820,8 @@ def destroy(self):
self._running = False
if hasattr(self, 'pub_channel'):
self.pub_channel.on_recv(None)
if hasattr(self.pub_channel, 'close'):
self.pub_channel.close()
del self.pub_channel
if hasattr(self, 'periodic_callbacks'):
for cb in six.itervalues(self.periodic_callbacks):
Expand Down
4 changes: 4 additions & 0 deletions salt/transport/tcp.py
Expand Up @@ -426,6 +426,10 @@ def close(self):
# 'StreamClosedError' when the stream is closed.
self._read_until_future.exc_info()
self._tcp_client.close()
# Clear callback references to allow the object that they belong to
# to be deleted.
self.connect_callback = None
self.disconnect_callback = None

def __del__(self):
self.close()
Expand Down
6 changes: 4 additions & 2 deletions salt/utils/schedule.py
Expand Up @@ -642,9 +642,11 @@ def handle_func(self, func, data):
except OSError:
log.info('Unable to remove file: {0}.'.format(fn_))

try:
salt.utils.daemonize_if(self.opts)
# Don't *BEFORE* to go into try to don't let it triple execute the finally section.
salt.utils.daemonize_if(self.opts)

# TODO: Make it readable! Splt to funcs, remove nested try-except-finally sections.
try:
ret['pid'] = os.getpid()

if 'jid_include' not in data or data['jid_include']:
Expand Down