diff mbox series

[ovs-dev,v2] python-stream: handle SSL error in do_handshake

Message ID 774b72b11fa2701fe334e38aeaab18c7ff74fd98.camel@cloudandheat.com
State Superseded
Headers show
Series [ovs-dev,v2] python-stream: handle SSL error in do_handshake | expand

Checks

Context Check Description
ovsrobot/apply-robot warning apply and check: warning
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/intel-ovs-compilation success test: success

Commit Message

Stefan Hoffmann April 21, 2023, 7:58 a.m. UTC
In some cases ovsdb server or relay gets restarted, ovsdb python clients
may keep the local socket open. Instead of reconnecting a lot of failures
will be logged.
This can be reproduced with ssl connections to the server/relay and
restarting it, so it has the same IP after restart.

This patch catches the Exceptions at do_handshake to recreate the
connection on the client side.

Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: Stefan Hoffmann <stefan.hoffmann@cloudandheat.com>
Co-authored-by: Luca Czesla <luca.czesla@mail.schwarz>
Co-authored-by: Max Lamprecht <max.lamprecht@mail.schwarz>
---
 python/ovs/stream.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/python/ovs/stream.py b/python/ovs/stream.py
index ac5b0fd0c..b32341076 100644
--- a/python/ovs/stream.py
+++ b/python/ovs/stream.py
@@ -824,7 +824,8 @@  class SSLStream(Stream):
             self.socket.do_handshake()
         except ssl.SSLWantReadError:
             return errno.EAGAIN
-        except ssl.SSLSyscallError as e:
+        except (ssl.SSLSyscallError, ssl.SSLZeroReturnError,
+                ssl.SSLEOFError, OSError) as e:
             return ovs.socket_util.get_exception_errno(e)
 
         return 0