Better handle termination; remove cluster info from keepalive printout
This commit is contained in:
parent
62b2718d7a
commit
3e2a6b8e80
|
@ -326,13 +326,18 @@ def cleanup():
|
||||||
|
|
||||||
# Force into secondary network state if needed
|
# Force into secondary network state if needed
|
||||||
if this_node.name == this_node.primary_node:
|
if this_node.name == this_node.primary_node:
|
||||||
|
is_primary = True
|
||||||
zkhandler.writedata(zk_conn, {
|
zkhandler.writedata(zk_conn, {
|
||||||
'/nodes/{}/routerstate'.format(myhostname): 'secondary',
|
'/nodes/{}/routerstate'.format(myhostname): 'secondary',
|
||||||
'/primary_node': 'none'
|
'/primary_node': 'none'
|
||||||
})
|
})
|
||||||
|
else:
|
||||||
|
is_primary = False
|
||||||
|
|
||||||
# Wait for things to flush
|
# Wait for things to flush
|
||||||
time.sleep(3)
|
if is_primary:
|
||||||
|
logger.out('Waiting for primary migration', state='s')
|
||||||
|
time.sleep(3)
|
||||||
|
|
||||||
# Set stop state in Zookeeper
|
# Set stop state in Zookeeper
|
||||||
zkhandler.writedata(zk_conn, { '/nodes/{}/daemonstate'.format(myhostname): 'stop' })
|
zkhandler.writedata(zk_conn, { '/nodes/{}/daemonstate'.format(myhostname): 'stop' })
|
||||||
|
@ -347,7 +352,7 @@ def cleanup():
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
logger.out('Exiting pvc daemon', state='s')
|
logger.out('Terminated pvc daemon', state='s')
|
||||||
|
|
||||||
# Handle exit gracefully
|
# Handle exit gracefully
|
||||||
atexit.register(cleanup)
|
atexit.register(cleanup)
|
||||||
|
@ -401,9 +406,9 @@ else:
|
||||||
# Check that the primary key exists, and create it with us as master if not
|
# Check that the primary key exists, and create it with us as master if not
|
||||||
current_primary = zkhandler.readdata(zk_conn, '/primary_node')
|
current_primary = zkhandler.readdata(zk_conn, '/primary_node')
|
||||||
if current_primary and current_primary != 'none':
|
if current_primary and current_primary != 'none':
|
||||||
logger.out('Current primary node is "{}{}{}".'.format(logger.fmt_blue, current_primary, logger.fmt_end), state='i')
|
logger.out('Current primary node is {}{}{}.'.format(logger.fmt_blue, current_primary, logger.fmt_end), state='i')
|
||||||
else:
|
else:
|
||||||
logger.out('No primary node key found; creating with us as primary.', state='i')
|
logger.out('No primary node found; creating with us as primary.', state='i')
|
||||||
zkhandler.writedata(zk_conn, { '/primary_node': myhostname })
|
zkhandler.writedata(zk_conn, { '/primary_node': myhostname })
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
@ -742,23 +747,6 @@ def update_zookeeper():
|
||||||
fence_thread = threading.Thread(target=fencing.fenceNode, args=(node_name, zk_conn, config, logger), kwargs={})
|
fence_thread = threading.Thread(target=fencing.fenceNode, args=(node_name, zk_conn, config, logger), kwargs={})
|
||||||
fence_thread.start()
|
fence_thread.start()
|
||||||
|
|
||||||
# Update the arrays
|
|
||||||
if node_domain_state == 'flushed':
|
|
||||||
flushed_node_list.append(node_name)
|
|
||||||
else:
|
|
||||||
if node_daemon_state == 'run':
|
|
||||||
active_node_list.append(node_name)
|
|
||||||
else:
|
|
||||||
inactive_node_list.append(node_name)
|
|
||||||
|
|
||||||
# List of the non-primary coordinators
|
|
||||||
secondary_node_list = this_node.config['coordinators'].split(',')
|
|
||||||
if secondary_node_list:
|
|
||||||
secondary_node_list.remove(this_node.primary_node)
|
|
||||||
for node in secondary_node_list:
|
|
||||||
if node in inactive_node_list:
|
|
||||||
secondary_node_list.remove(node)
|
|
||||||
|
|
||||||
# Display node information to the terminal
|
# Display node information to the terminal
|
||||||
logger.out('{}{} keepalive{}'.format(logger.fmt_purple, this_node.name, logger.fmt_end), state='t')
|
logger.out('{}{} keepalive{}'.format(logger.fmt_purple, this_node.name, logger.fmt_end), state='t')
|
||||||
logger.out(
|
logger.out(
|
||||||
|
@ -779,14 +767,6 @@ def update_zookeeper():
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Display cluster information to the terminal
|
|
||||||
logger.out('{}Cluster status{}'.format(logger.fmt_purple, logger.fmt_end), state='t')
|
|
||||||
logger.out('{}Primary coordinator:{} {}'.format(logger.fmt_bold, logger.fmt_end, this_node.primary_node))
|
|
||||||
logger.out('{}Secondary coordinators:{} {}'.format(logger.fmt_bold, logger.fmt_end, ' '.join(secondary_node_list)))
|
|
||||||
logger.out('{}Active hypervisors:{} {}'.format(logger.fmt_bold, logger.fmt_end, ' '.join(active_node_list)))
|
|
||||||
logger.out('{}Flushed hypervisors:{} {}'.format(logger.fmt_bold, logger.fmt_end, ' '.join(flushed_node_list)))
|
|
||||||
logger.out('{}Inactive nodes:{} {}'.format(logger.fmt_bold, logger.fmt_end, ' '.join(inactive_node_list)))
|
|
||||||
|
|
||||||
# Start keepalive thread and immediately update Zookeeper
|
# Start keepalive thread and immediately update Zookeeper
|
||||||
startKeepaliveTimer()
|
startKeepaliveTimer()
|
||||||
update_zookeeper()
|
update_zookeeper()
|
||||||
|
|
Loading…
Reference in New Issue