From c93917e4a42c40b3da2ee777856cf6538d77b691 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 30 Sep 2021 08:18:39 -0400 Subject: [PATCH] Add a failsafe for errors trying to connect to a new leader Provide better experience in the face of the class of errors such as the one fixed by previous commit. --- confluent_server/confluent/collective/manager.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/confluent_server/confluent/collective/manager.py b/confluent_server/confluent/collective/manager.py index 7e597176..b0b99a7f 100644 --- a/confluent_server/confluent/collective/manager.py +++ b/confluent_server/confluent/collective/manager.py @@ -184,8 +184,12 @@ def follow_leader(remote, leader): if newleader: log.log( {'info': 'Previous leader directed us to join new leader {}'.format(newleader)}) - if connect_to_leader(None, get_myname(), newleader): - return + try: + if connect_to_leader(None, get_myname(), newleader): + return + except Exception: + log.log({'error': 'Unknown error attempting to connect to {}, check trace log'.format(newleader), 'subsystem': 'collective'}) + cfm.logException() log.log({'info': 'Current leader ({0}) has disappeared, restarting ' 'collective membership'.format(leader), 'subsystem': 'collective'}) # The leader has folded, time to startup again...