PY3: Fix exception when handling connect exception in TCP transport (#37831)

When `self.auth.authenticate()` would throw this exception:
`raise SaltClientError(
'Attempt to authenticate with the salt master failed with timeout error')`

The code would throw an additional exception dealing with the original
exception as follows:

```
  File "...\salt\transport\tcp.py", line 500, in connect
      if '-|RETRY|-' not in exc:
      TypeError: argument of type 'SaltClientError' is not iterable
```

And since the final exception being thrown is `TypeError` instead of
`SaltClientError`, caller code would not correctly deal with this
case and the salt-minion would terminate.

Fix this by using Python 3 friendly `str(exc)` instead of plain
`exc` when doing a string search.

Signed-off-by: Sergey Kizunov <sergey.kizunov@ni.com>
This commit is contained in:
Sergey Kizunov 2016-11-22 10:27:04 -05:00 committed by Nicole Thomas
parent dd81d2fa67
commit 2bc42b8484

View file

@ -497,7 +497,7 @@ class AsyncTCPPubChannel(salt.transport.mixins.auth.AESPubClientMixin, salt.tran
except KeyboardInterrupt:
raise
except Exception as exc:
if '-|RETRY|-' not in exc:
if '-|RETRY|-' not in str(exc):
raise SaltClientError('Unable to sign_in to master: {0}'.format(exc)) # TODO: better error message
def on_recv(self, callback):