Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make salt-broker reconnecting on master IP change #9074

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions proxy/proxy/salt-broker/salt-broker
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand All @@ -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:
Expand Down Expand Up @@ -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
vzhestkov marked this conversation as resolved.
Show resolved Hide resolved
and self.opts["wait_for_backend"]
):
continue
if self.reconnect_retries == 0:
log.warning(
"Closing {} socket due to retry attempts reached!".format(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Make salt-broker reconnecting if master IP has changed
Loading