From b08834282082078d79dda07f8061586795145151 Mon Sep 17 00:00:00 2001 From: vzhestkov Date: Fri, 19 Jul 2024 12:39:20 +0200 Subject: [PATCH 1/2] Make salt-broker reconnecting if master IP has changed --- proxy/proxy/salt-broker/salt-broker | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/proxy/proxy/salt-broker/salt-broker b/proxy/proxy/salt-broker/salt-broker index a014c4d46e3f..5b99f280bfb1 100755 --- a/proxy/proxy/salt-broker/salt-broker +++ b/proxy/proxy/salt-broker/salt-broker @@ -85,7 +85,6 @@ class AbstractChannelProxy(multiprocessing.Process): def __init__(self, opts): self.opts = opts self.backend_connected = False - self.backend_ever_connected = False if "master" not in self.opts: raise self.ChannelException( '[{}] No "master" opts is provided'.format( @@ -126,6 +125,12 @@ class AbstractChannelProxy(multiprocessing.Process): if self.opts["wait_for_backend"]: while not self.backend_connected: + if self.backend.closed: + log.warning( + "Backend %s socket was closed while waiting for it. Terminating...", + self.backend_type, + ) + return time.sleep(0.5) log.debug( @@ -140,7 +145,16 @@ class AbstractChannelProxy(multiprocessing.Process): self.frontend.bind(self._frontend_uri) # Forward all messages - zmq.proxy(self.frontend, self.backend) + log.info("Staring ZMQ proxy on %s and %s sockets", self.frontend_type, self.backend_type) + try: + zmq.proxy(self.frontend, self.backend) + except Exception as e: + log.error( + "Error while processing proxy with %s and %s sockets. Terminating...", + self.frontend_type, + self.backend_type + ) + return except zmq.ZMQError as zmq_error: if self.reconnect_retries == 0: @@ -172,14 +186,8 @@ class AbstractChannelProxy(multiprocessing.Process): elif mon_evt["event"] == zmq.EVENT_CONNECTED: log.info("{} socket connected".format(self.backend_type)) self.backend_connected = True - self.backend_ever_connected = True self.reconnect_retries = self.opts["drop_after_retries"] elif mon_evt["event"] == zmq.EVENT_CONNECT_RETRIED: - if ( - not self.backend_ever_connected - and self.opts["wait_for_backend"] - ): - continue if self.reconnect_retries == 0: log.warning( "Closing {} socket due to retry attempts reached!".format( From 8eeb982f29a6eb5276ffb713d2cd4db4452c46f6 Mon Sep 17 00:00:00 2001 From: vzhestkov Date: Fri, 19 Jul 2024 12:40:32 +0200 Subject: [PATCH 2/2] Add changelog entry --- ...alk-proxy.changes.vzhestkov.make-salt-broker-master-ip-change | 1 + 1 file changed, 1 insertion(+) create mode 100644 proxy/proxy/spacewalk-proxy.changes.vzhestkov.make-salt-broker-master-ip-change diff --git a/proxy/proxy/spacewalk-proxy.changes.vzhestkov.make-salt-broker-master-ip-change b/proxy/proxy/spacewalk-proxy.changes.vzhestkov.make-salt-broker-master-ip-change new file mode 100644 index 000000000000..58581ac5020e --- /dev/null +++ b/proxy/proxy/spacewalk-proxy.changes.vzhestkov.make-salt-broker-master-ip-change @@ -0,0 +1 @@ +- Make salt-broker reconnecting if master IP has changed