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

Back-port #33948 and #34009 to 2015.8 #34011

Merged
merged 4 commits into from
Jun 16, 2016
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions doc/topics/releases/2015.8.11.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
============================
Salt 2015.8.11 Release Notes
============================

Version 2015.8.11 is a bugfix release for :doc:`2015.8.0
</topics/releases/2015.8.0>`.

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.
36 changes: 28 additions & 8 deletions salt/master.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import salt.daemons.masterapi
import salt.defaults.exitcodes
import salt.transport.server
import salt.utils.args
import salt.utils.atomicfile
import salt.utils.event
import salt.utils.job
Expand Down Expand Up @@ -2107,21 +2108,40 @@ def _prep_pub(self, minions, jid, clear_load, extra):
self.event.fire_event(new_job_load, tagify([clear_load['jid'], 'new'], 'job'))

if self.opts['ext_job_cache']:
fstr = '{0}.save_load'.format(self.opts['ext_job_cache'])
save_load_func = True

# Get the returner's save_load arg_spec.
try:
fstr = '{0}.save_load'.format(self.opts['ext_job_cache'])
self.mminion.returners[fstr](clear_load['jid'], clear_load)
except KeyError:
arg_spec = salt.utils.args.get_function_argspec(fstr)

# Check if 'minions' is included in returner's save_load arg_spec.
# This may be missing in custom returners, which we should warn about.
if 'minions' not in arg_spec.args:
log.critical(
'The specified returner used for the external job cache '
'\'{0}\' does not have a \'minions\' kwarg in the returner\'s '
'save_load function.'.format(
self.opts['ext_job_cache']
)
)
except AttributeError:
save_load_func = False
log.critical(
'The specified returner used for the external job cache '
'"{0}" does not have a save_load function!'.format(
self.opts['ext_job_cache']
)
)
except Exception:
log.critical(
'The specified returner threw a stack trace:\n',
exc_info=True
)

if save_load_func:
try:
self.mminion.returners[fstr](clear_load['jid'], clear_load, minions=minions)
except Exception:
log.critical(
'The specified returner threw a stack trace:\n',
exc_info=True
)

# always write out to the master job caches
try:
Expand Down
2 changes: 1 addition & 1 deletion salt/returners/cassandra_cql_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
'''
Expand Down
2 changes: 1 addition & 1 deletion salt/returners/couchbase_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
'''
Expand Down
2 changes: 1 addition & 1 deletion salt/returners/django_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
'''
Expand Down
2 changes: 1 addition & 1 deletion salt/returners/elasticsearch_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,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

Expand Down
2 changes: 1 addition & 1 deletion salt/returners/etcd_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def returner(ret):
client.write(dest, json.dumps(ret[field]))


def save_load(jid, load):
def save_load(jid, load, minions=None):
'''
Save the load to the specified jid
'''
Expand Down
2 changes: 1 addition & 1 deletion salt/returners/influxdb_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,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
'''
Expand Down
2 changes: 1 addition & 1 deletion salt/returners/memcache_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def returner(ret):
serv.add('jids', ret['jid'] + ',')


def save_load(jid, load):
def save_load(jid, load, minions=None):
'''
Save the load to the specified jid
'''
Expand Down
2 changes: 1 addition & 1 deletion salt/returners/mongo_future_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,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
'''
Expand Down
2 changes: 1 addition & 1 deletion salt/returners/multi_returner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
'''
Expand Down
2 changes: 1 addition & 1 deletion salt/returners/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,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
'''
Expand Down
2 changes: 1 addition & 1 deletion salt/returners/odbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,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
'''
Expand Down
2 changes: 1 addition & 1 deletion salt/returners/pgjsonb.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,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
'''
Expand Down
2 changes: 1 addition & 1 deletion salt/returners/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,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
'''
Expand Down
2 changes: 1 addition & 1 deletion salt/returners/postgres_local_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def returner(load):
_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
'''
Expand Down
2 changes: 1 addition & 1 deletion salt/returners/redis_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def returner(ret):
pipe.execute()


def save_load(jid, load):
def save_load(jid, load, minions=None):
'''
Save the load to the specified jid
'''
Expand Down
2 changes: 1 addition & 1 deletion salt/returners/sqlite3_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,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
'''
Expand Down
11 changes: 7 additions & 4 deletions salt/utils/minions.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ def check_minions(self,
minions = []
return minions

def validate_tgt(self, valid, expr, expr_form):
def validate_tgt(self, valid, expr, expr_form, minions=None):
'''
Return a Bool. This function returns if the expression sent in is
within the scope of the valid expression
Expand All @@ -655,7 +655,8 @@ def validate_tgt(self, valid, expr, expr_form):
v_expr = target_info['pattern']

v_minions = set(self.check_minions(v_expr, v_matcher))
minions = set(self.check_minions(expr, expr_form))
if minions is None:
minions = set(self.check_minions(expr, expr_form))
d_bool = not bool(minions.difference(v_minions))
if len(v_minions) == len(minions) and d_bool:
return True
Expand Down Expand Up @@ -701,7 +702,8 @@ def auth_check(self,
tgt,
tgt_type='glob',
groups=None,
publish_validate=False):
publish_validate=False,
minions=None):
'''
Returns a bool which defines if the requested function is authorized.
Used to evaluate the standard structure under external master
Expand Down Expand Up @@ -740,7 +742,8 @@ def auth_check(self,
if self.validate_tgt(
valid,
tgt,
tgt_type):
tgt_type,
minions=minions):
# Minions are allowed, verify function in allowed list
if isinstance(ind[valid], six.string_types):
if self.match_check(ind[valid], fun):
Expand Down