- add option for syndics to forward all events to all masters

This commit is contained in:
Andreas Tsaridas 2016-12-02 01:44:55 +01:00
parent 47956ffd0c
commit 342ca788db
2 changed files with 14 additions and 3 deletions

View File

@ -637,6 +637,7 @@ VALID_OPTS = {
# specify 'random' (default) or 'ordered'. If set to 'random' masters will be iterated in random # specify 'random' (default) or 'ordered'. If set to 'random' masters will be iterated in random
# order if 'ordered' the configured order will be used. # order if 'ordered' the configured order will be used.
'syndic_failover': str, 'syndic_failover': str,
'syndic_forward_all_events': bool,
'runner_dirs': list, 'runner_dirs': list,
'client_acl': dict, 'client_acl': dict,
'client_acl_verify': bool, 'client_acl_verify': bool,
@ -1290,6 +1291,7 @@ DEFAULT_MASTER_OPTS = {
'preserve_minion_cache': False, 'preserve_minion_cache': False,
'syndic_master': '', 'syndic_master': '',
'syndic_failover': 'random', 'syndic_failover': 'random',
'syndic_forward_all_events': False,
'syndic_log_file': os.path.join(salt.syspaths.LOGS_DIR, 'syndic'), 'syndic_log_file': os.path.join(salt.syspaths.LOGS_DIR, 'syndic'),
'syndic_pidfile': os.path.join(salt.syspaths.PIDFILE_DIR, 'salt-syndic.pid'), 'syndic_pidfile': os.path.join(salt.syspaths.PIDFILE_DIR, 'salt-syndic.pid'),
'runner_dirs': [], 'runner_dirs': [],

View File

@ -2548,6 +2548,7 @@ class SyndicManager(MinionBase):
''' '''
Wrapper to call a given func on a syndic, best effort to get the one you asked for Wrapper to call a given func on a syndic, best effort to get the one you asked for
''' '''
success = False
if kwargs is None: if kwargs is None:
kwargs = {} kwargs = {}
for master, syndic_future in self.iter_master_options(master_id): for master, syndic_future in self.iter_master_options(master_id):
@ -2557,17 +2558,22 @@ class SyndicManager(MinionBase):
try: try:
getattr(syndic_future.result(), func)(*args, **kwargs) getattr(syndic_future.result(), func)(*args, **kwargs)
success = True
if self.opts['syndic_forward_events'] == 'all':
continue
return return
except SaltClientError: except SaltClientError:
log.error('Unable to call {0} on {1}, trying another...'.format(func, master)) log.error('Unable to call {0} on {1}, trying another...'.format(func, master))
self._mark_master_dead(master) self._mark_master_dead(master)
continue continue
log.critical('Unable to call {0} on any masters!'.format(func)) if not success:
log.critical('Unable to call {0} on any masters!'.format(func))
def _return_pub_syndic(self, values, master_id=None): def _return_pub_syndic(self, values, master_id=None):
''' '''
Wrapper to call the '_return_pub_multi' a syndic, best effort to get the one you asked for Wrapper to call the '_return_pub_multi' a syndic, best effort to get the one you asked for
''' '''
success = True
func = '_return_pub_multi' func = '_return_pub_multi'
for master, syndic_future in self.iter_master_options(master_id): for master, syndic_future in self.iter_master_options(master_id):
if not syndic_future.done() or syndic_future.exception(): if not syndic_future.done() or syndic_future.exception():
@ -2593,9 +2599,12 @@ class SyndicManager(MinionBase):
continue continue
future = getattr(syndic_future.result(), func)(values) future = getattr(syndic_future.result(), func)(values)
self.pub_futures[master] = (future, values) self.pub_futures[master] = (future, values)
return True success = True
if self.opts['syndic_forward_events'] == 'all':
continue
break
# Loop done and didn't exit: wasn't sent, try again later # Loop done and didn't exit: wasn't sent, try again later
return False return success
def iter_master_options(self, master_id=None): def iter_master_options(self, master_id=None):
''' '''