Add further tweaks to takeover state checks

Just ensure that everything is proper state before proceeding
This commit is contained in:
Joshua Boniface 2020-04-22 09:45:23 -04:00
parent ae4f36b881
commit 331027d124
1 changed files with 4 additions and 3 deletions

View File

@ -830,7 +830,7 @@ def update_primary(new_primary, stat, event=''):
if config['daemon_mode'] == 'coordinator': if config['daemon_mode'] == 'coordinator':
# We're a coordinator and there is no primary # We're a coordinator and there is no primary
if new_primary == 'none': if new_primary == 'none':
if this_node.daemon_state == 'run' and this_node.router_state == 'secondary': if this_node.daemon_state == 'run' and this_node.router_state not in ['primary', 'takeover', 'relinquish']:
logger.out('Contending for primary coordinator state', state='i') logger.out('Contending for primary coordinator state', state='i')
# Acquire an exclusive lock on the primary_node key # Acquire an exclusive lock on the primary_node key
primary_lock = zkhandler.exclusivelock(zk_conn, '/primary_node') primary_lock = zkhandler.exclusivelock(zk_conn, '/primary_node')
@ -849,6 +849,7 @@ def update_primary(new_primary, stat, event=''):
except kazoo.exceptions.LockTimeout: except kazoo.exceptions.LockTimeout:
pass pass
elif new_primary == myhostname: elif new_primary == myhostname:
if this_node.router_state == 'secondary':
time.sleep(0.5) time.sleep(0.5)
zkhandler.writedata(zk_conn, {'/nodes/{}/routerstate'.format(myhostname): 'takeover'}) zkhandler.writedata(zk_conn, {'/nodes/{}/routerstate'.format(myhostname): 'takeover'})
else: else: