Expose SERVER_DOWN if connection fails

Without this change, ldappool might fail to bind to an LDAP server for
any number of reasons, but eats most of them and instead raises its own
not-very-descriptive error. A network failure or the LDAP server being
down is useful information that a user might be able to do something
with (see this related patch[1]) so let's add that to the list of
exceptions ldappool raises directly.

[1] https://review.openstack.org/#/c/390948

Change-Id: Iebb58f9046707a044ed86d8ce940e4c230ffd2aa
This commit is contained in:
Colleen Murphy 2016-11-08 16:01:04 +01:00
parent 38003f190c
commit 5d69b3fed7
2 changed files with 3 additions and 2 deletions

View File

@ -267,7 +267,8 @@ class ConnectionManager(object):
if not connected:
if isinstance(exc, (ldap.NO_SUCH_OBJECT,
ldap.INVALID_CREDENTIALS)):
ldap.INVALID_CREDENTIALS,
ldap.SERVER_DOWN)):
raise exc
# that's something else

View File

@ -133,7 +133,7 @@ class TestLDAPConnection(unittest.TestCase):
try:
with cm.connection('dn', 'pass'):
pass
except ldappool.BackendError:
except ldap.SERVER_DOWN:
pass
else:
raise AssertionError()