mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Warn when custom returners don't have minions kwarg in save_load
This commit is contained in:
parent
c776d2d795
commit
239af9ae5e
1 changed files with 28 additions and 8 deletions
|
@ -62,6 +62,7 @@ import salt.daemons.masterapi
|
|||
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
|
||||
|
@ -2259,21 +2260,40 @@ class ClearFuncs(object):
|
|||
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, minions=minions)
|
||||
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:
|
||||
|
|
Loading…
Add table
Reference in a new issue