saltstack/salt — pull request #1029 by fatbox (2012-03-31 20:44:44+00:00)
Title: 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.