mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Handle ValueError's when parsing 'tmo' with int()
This is a rather obscure one but it just bit us so I figured we should fix it. A recent change to our code that invokes salt through the Python API ended up doing this: ret = minion.functions['publish.publish'](self.name, fun, *args, **kwargs) When we really meant to do this: ret = minion.functions['publish.publish'](self.name, fun, arg=args, **kwargs) What made this difficult to track down was that the master would just silently die when this happened. Once we ran it in debug mode we found the following exception: 16:14:30,049 [salt.master ][INFO ] AES payload received with command minion_publish Process MWorker-5: Traceback (most recent call last): File "/usr/lib/python2.6/multiprocessing/process.py", line 232, in _bootstrap self.run() File "/usr/lib/python2.6/dist-packages/salt/master.py", line 368, in run self.__bind() File "/usr/lib/python2.6/dist-packages/salt/master.py", line 317, in __bind ret = self.serial.dumps(self._handle_payload(payload)) File "/usr/lib/python2.6/dist-packages/salt/master.py", line 335, in _handle_payload 'clear': self._handle_clear}[key](load) File "/usr/lib/python2.6/dist-packages/salt/master.py", line 362, in _handle_aes return self.aes_funcs.run_func(data['cmd'], data) File "/usr/lib/python2.6/dist-packages/salt/master.py", line 775, in run_func ret = getattr(self, func)(load) File "/usr/lib/python2.6/dist-packages/salt/master.py", line 722, in minion_publish timeout = int(clear_load['tmo']) ValueError: invalid literal for int() with base 10: ',00:16:36:9d:d9:30,' With these changes the master will now log a warning and return gracefully. Also, I fixed a small syntax error that suggested clear_load was a function.
This commit is contained in:
parent
e3fe0c05fc
commit
3544d580f4
@ -718,12 +718,17 @@ class AESFuncs(object):
|
||||
expr_form = 'glob'
|
||||
timeout = 5
|
||||
if 'tmo' in clear_load:
|
||||
timeout = int(clear_load['tmo'])
|
||||
try:
|
||||
timeout = int(clear_load['tmo'])
|
||||
except ValueError:
|
||||
msg = 'Failed to parse timeout value: {0}'.format(clear_load['tmo'])
|
||||
log.warn(msg)
|
||||
return {}
|
||||
if 'tgt_type' in clear_load:
|
||||
load['tgt_type'] = clear_load['tgt_type']
|
||||
expr_form = load['tgt_type']
|
||||
if 'timeout' in clear_load:
|
||||
timeout = clear_load('timeout')
|
||||
timeout = clear_load['timeout']
|
||||
# Encrypt!
|
||||
payload['load'] = self.crypticle.dumps(load)
|
||||
# Connect to the publisher
|
||||
|
Loading…
Reference in New Issue
Block a user