From 00d2c67c411030b875c52e74e71e2d66ef484df4 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Tue, 28 Dec 2021 03:06:03 -0500 Subject: [PATCH] Allow single-node clusters to restart and timeout Prevents a daemon from waiting forever to terminate if it is primary, and avoids this entirely if there is only a single node in the cluster. --- node-daemon/pvcnoded/Daemon.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/node-daemon/pvcnoded/Daemon.py b/node-daemon/pvcnoded/Daemon.py index 023be56f..74a80ba8 100644 --- a/node-daemon/pvcnoded/Daemon.py +++ b/node-daemon/pvcnoded/Daemon.py @@ -233,11 +233,14 @@ def entrypoint(): # Force into secondary coordinator state if needed try: - if this_node.router_state == "primary": + if this_node.router_state == "primary" and len(d_node) > 1: zkhandler.write([("base.config.primary_node", "none")]) logger.out("Waiting for primary migration", state="s") - while this_node.router_state != "secondary": + timeout = 240 + count = 0 + while this_node.router_state != "secondary" and count < timeout: sleep(0.5) + count += 1 except Exception: pass