From 9a779f2dd2df7b5d28d9be834658e6a2e675cc60 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 7 Apr 2021 07:58:10 -0400 Subject: [PATCH] Improve collective startup behavior Have confluent focus on establishing quorum before initiating headless console and discovery activity. --- confluent_server/confluent/main.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/confluent_server/confluent/main.py b/confluent_server/confluent/main.py index 1e64d654..86300a72 100644 --- a/confluent_server/confluent/main.py +++ b/confluent_server/confluent/main.py @@ -244,7 +244,7 @@ def run(args): _updatepidfile() signal.signal(signal.SIGINT, terminate) signal.signal(signal.SIGTERM, terminate) - collective.startup() + atexit.register(doexit) if dbgif: oumask = os.umask(0o077) try: @@ -258,19 +258,27 @@ def run(args): except AttributeError: pass # Windows... os.umask(oumask) + collective.startup() + consoleserver.initialize() http_bind_host, http_bind_port = _get_connector_config('http') sock_bind_host, sock_bind_port = _get_connector_config('socket') - consoleserver.initialize() - webservice = httpapi.HttpApi(http_bind_host, http_bind_port) - webservice.start() - disco.start_detection() - pxe.start_proxydhcp() try: sockservice = sockapi.SockApi(sock_bind_host, sock_bind_port) sockservice.start() except NameError: pass - atexit.register(doexit) + webservice = httpapi.HttpApi(http_bind_host, http_bind_port) + webservice.start() + while len(configmanager.list_collective) >= 2: + # If in a collective, stall automatic startup activity + # until we establish quorum + try: + configmanager.check_quorum() + break + except Exception: + eventlet.sleep(0.5) + disco.start_detection() + pxe.start_proxydhcp() eventlet.sleep(1) consoleserver.start_console_sessions() while 1: