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 to 2016.3 + add log message #34009

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/2016.3.2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
===========================
Salt 2016.3.2 Release Notes
===========================

Version 2016.3.2 is a bugfix release for :doc:`2016.3.0
</topics/releases/2016.3.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 @@ -62,6 +62,7 @@
import salt.defaults.exitcodes
import salt.transport.server
import salt.log.setup
import salt.utils.args
import salt.utils.atomicfile
import salt.utils.event
import salt.utils.job
Expand Down Expand Up @@ -2259,21 +2260,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 @@ -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
'''
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 @@ -137,7 +137,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 @@ -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
'''
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 @@ -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
'''
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 @@ -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
'''
Expand Down
2 changes: 1 addition & 1 deletion salt/returners/odbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
'''
Expand Down
2 changes: 1 addition & 1 deletion salt/returners/pgjsonb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
'''
Expand Down
2 changes: 1 addition & 1 deletion salt/returners/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
'''
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 @@ -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
'''
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 @@ -120,7 +120,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
'''
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 @@ -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
'''
Expand Down
11 changes: 7 additions & 4 deletions salt/utils/minions.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,13 +654,14 @@ def _expand_matching(self, auth_entry):

return set(self.check_minions(v_expr, v_matcher))

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
'''
v_minions = self._expand_matching(valid)
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 @@ -818,7 +819,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 @@ -860,7 +862,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