Save an entire minion cache traversal on each master pub

We were doing an extra and unecessary full traversal of the minion
cache. This refactors all returners and the master to reduce this
to a single call. More work will be forthcoming to reduce this even
further, especially in the context of auth lookups.
This commit is contained in:
Mike Place 2016-06-10 15:43:08 -06:00
parent e1beac55c5
commit 98f3a482ac
18 changed files with 24 additions and 17 deletions

View File

@ -39,6 +39,13 @@ Beacons Changes
- The ``loadavg`` beacon now outputs averages as integers instead of strings.
(Via :issuse:`31124`.)
Returner Changes
================
- Any returner which implements a `save_load` function is now required to
accept a `minions` keyword argument. All returners which ship with Salt
have been modified to do so.
External Module Packaging
=========================

View File

@ -2266,7 +2266,7 @@ class ClearFuncs(object):
if self.opts['ext_job_cache']:
try:
fstr = '{0}.save_load'.format(self.opts['ext_job_cache'])
self.mminion.returners[fstr](clear_load['jid'], clear_load)
self.mminion.returners[fstr](clear_load['jid'], clear_load, minions=minions)
except KeyError:
log.critical(
'The specified returner used for the external job cache '

View File

@ -236,7 +236,7 @@ def event_return(events):
raise
def save_load(jid, load):
def save_load(jid, load, minions=None):
'''
Save the load to the specified jid id
'''

View File

@ -184,7 +184,7 @@ def returner(load):
return False
def save_load(jid, clear_load):
def save_load(jid, clear_load, minion=None):
'''
Save the load to the specified jid
'''

View File

@ -65,7 +65,7 @@ def returner(ret):
'which responded with {1}'.format(signal[0], signal[1]))
def save_load(jid, load):
def save_load(jid, load, minions=None):
'''
Save the load to the specified jid
'''

View File

@ -164,7 +164,7 @@ def prep_jid(nocache=False, passed_jid=None): # pylint: disable=unused-argument
return passed_jid if passed_jid is not None else salt.utils.jid.gen_jid()
def save_load(jid, load):
def save_load(jid, load, minions=None):
'''
Save the load to the specified jid id

View File

@ -133,7 +133,7 @@ def returner(ret):
client.set(dest, json.dumps(ret[field]), ttl=ttl)
def save_load(jid, load):
def save_load(jid, load, minions=None):
'''
Save the load to the specified jid
'''

View File

@ -189,7 +189,7 @@ def returner(ret):
log.critical('Failed to store return with InfluxDB returner: {0}'.format(ex))
def save_load(jid, load):
def save_load(jid, load, minions=None):
'''
Save the load to the specified jid
'''

View File

@ -154,7 +154,7 @@ def returner(ret):
_append_list(serv, 'jids', jid)
def save_load(jid, load):
def save_load(jid, load, minions=None):
'''
Save the load to the specified jid
'''

View File

@ -199,7 +199,7 @@ def returner(ret):
mdb.saltReturns.insert(sdata.copy())
def save_load(jid, load):
def save_load(jid, load, minions=None):
'''
Save the load for a given job id
'''

View File

@ -61,7 +61,7 @@ def returner(load):
_mminion().returners['{0}.returner'.format(returner_)](load)
def save_load(jid, clear_load):
def save_load(jid, clear_load, minions=None):
'''
Write load to all returners in multi_returner
'''

View File

@ -287,7 +287,7 @@ def event_return(events):
cur.execute(sql, (tag, json.dumps(data), __opts__['id']))
def save_load(jid, load):
def save_load(jid, load, minions=None):
'''
Save the load to the specified jid id
'''

View File

@ -214,7 +214,7 @@ def returner(ret):
_close_conn(conn)
def save_load(jid, load):
def save_load(jid, load, minions=None):
'''
Save the load to the specified jid id
'''

View File

@ -272,7 +272,7 @@ def event_return(events):
__opts__['id'], time.strftime('%Y-%m-%d %H:%M:%S %z', time.localtime())))
def save_load(jid, load):
def save_load(jid, load, minions=None):
'''
Save the load to the specified jid id
'''

View File

@ -189,7 +189,7 @@ def returner(ret):
_close_conn(conn)
def save_load(jid, load):
def save_load(jid, load, minions=None):
'''
Save the load to the specified jid id
'''

View File

@ -264,7 +264,7 @@ def event_return(events):
_close_conn(conn)
def save_load(jid, clear_load):
def save_load(jid, clear_load, minions=None):
'''
Save the load to the specified jid id
'''

View File

@ -128,7 +128,7 @@ def returner(ret):
pipeline.execute()
def save_load(jid, load):
def save_load(jid, load, minions=None):
'''
Save the load to the specified jid
'''

View File

@ -178,7 +178,7 @@ def returner(ret):
_close_conn(conn)
def save_load(jid, load):
def save_load(jid, load, minions=None):
'''
Save the load to the specified jid
'''