From a0cf68acc062b50fef0b84a8fb3afe524a8565ef Mon Sep 17 00:00:00 2001 From: Mike Place Date: Thu, 8 Jan 2015 17:41:43 -0700 Subject: [PATCH] Don't let sys exits bubble into the reactor. Though async should prevent this, here is an additional layer of safety to prevent an uncaught exit from killing a master --- salt/utils/reactor.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/salt/utils/reactor.py b/salt/utils/reactor.py index 9d657400a5..6b76af0960 100644 --- a/salt/utils/reactor.py +++ b/salt/utils/reactor.py @@ -135,7 +135,10 @@ class Reactor(multiprocessing.Process, salt.state.Compiler): continue chunks = self.reactions(data['tag'], data['data'], reactors) if chunks: - self.call_reactions(chunks) + try: + self.call_reactions(chunks) + except SystemExit: + log.warning('Exit ignored by reactor') class ReactWrap(object): @@ -176,7 +179,10 @@ class ReactWrap(object): ''' if 'local' not in self.client_cache: self.client_cache['local'] = salt.client.LocalClient(self.opts['conf_file']) - self.client_cache['local'].cmd_async(*args, **kwargs) + try: + self.client_cache['local'].cmd_async(*args, **kwargs) + except SystemExit: + log.warning('Attempt to exit reactor. Ignored.') cmd = local @@ -186,7 +192,10 @@ class ReactWrap(object): ''' if 'runner' not in self.client_cache: self.client_cache['runner'] = salt.runner.RunnerClient(self.opts) - self.pool.fire_async(self.client_cache['runner'].low, args=(fun, kwargs)) + try: + self.pool.fire_async(self.client_cache['runner'].low, args=(fun, kwargs)) + except SystemExit: + log.warning('Attempt to exit in reactor by runner. Ignored') def wheel(self, fun, **kwargs): ''' @@ -194,4 +203,7 @@ class ReactWrap(object): ''' if 'wheel' not in self.client_cache: self.client_cache['wheel'] = salt.wheel.Wheel(self.opts) - self.pool.fire_async(self.client_cache['wheel'].low, args=(fun, kwargs)) + try: + self.pool.fire_async(self.client_cache['wheel'].low, args=(fun, kwargs)) + except SystemExit: + log.warning('Attempt to in reactor by whell. Ignored.')