Skip to content

Commit 4a5d0c3

Browse files
phlogistonjohnmergify[bot]
authored andcommitted
kmip: correct how we catch errors connecting to kmip servers
The client.open method is what actually causes the exceptions to be raised so we need to handle it properly. Signed-off-by: John Mulligan <[email protected]>
1 parent ec63e50 commit 4a5d0c3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

sambacc/kmip/scope.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,17 @@ def _client(self) -> typing.Iterator[ProxyKmipClient]:
103103
ca=self.tls_paths.ca_cert,
104104
kmip_version=self._kmip_version,
105105
)
106+
client.open()
106107
except OSError as err:
107108
_logger.warning("failed to connect to %r: %s", hostname, err)
109+
_logger.debug("KMIP connect failure details", exc_info=True)
108110
continue
109111
try:
110-
client.open()
111112
yield client
112113
finally:
113114
client.close()
114115
return
116+
_logger.warning("exhausted list of KMIP hosts to try")
115117
raise OSError(errno.EHOSTUNREACH, "failed to connect to any host")
116118

117119
@contextlib.contextmanager

0 commit comments

Comments
 (0)