Improve fence locking; use consistent ZK lock names
This commit is contained in:
parent
3ff4e9da29
commit
52a9a0e075
|
@ -682,8 +682,8 @@ def cmd(data, stat, event=''):
|
||||||
node, device, weight = args.split(',')
|
node, device, weight = args.split(',')
|
||||||
if node == this_node.name:
|
if node == this_node.name:
|
||||||
# Lock the command queue
|
# Lock the command queue
|
||||||
lock = zkhandler.writelock(zk_conn, '/ceph/cmd')
|
zk_lock = zkhandler.writelock(zk_conn, '/ceph/cmd')
|
||||||
with lock:
|
with zk_lock:
|
||||||
# Add the OSD
|
# Add the OSD
|
||||||
result = CephInstance.add_osd(zk_conn, logger, node, device, weight)
|
result = CephInstance.add_osd(zk_conn, logger, node, device, weight)
|
||||||
# Command succeeded
|
# Command succeeded
|
||||||
|
@ -703,8 +703,8 @@ def cmd(data, stat, event=''):
|
||||||
# Verify osd_id is in the list
|
# Verify osd_id is in the list
|
||||||
if d_osd[osd_id] and d_osd[osd_id].node == this_node.name:
|
if d_osd[osd_id] and d_osd[osd_id].node == this_node.name:
|
||||||
# Lock the command queue
|
# Lock the command queue
|
||||||
lock = zkhandler.writelock(zk_conn, '/ceph/cmd')
|
zk_lock = zkhandler.writelock(zk_conn, '/ceph/cmd')
|
||||||
with lock:
|
with zk_lock:
|
||||||
# Remove the OSD
|
# Remove the OSD
|
||||||
result = CephInstance.remove_osd(zk_conn, logger, osd_id, d_osd[osd_id])
|
result = CephInstance.remove_osd(zk_conn, logger, osd_id, d_osd[osd_id])
|
||||||
# Command succeeded
|
# Command succeeded
|
||||||
|
@ -724,8 +724,8 @@ def cmd(data, stat, event=''):
|
||||||
# Verify osd_id is in the list
|
# Verify osd_id is in the list
|
||||||
if d_osd[osd_id] and d_osd[osd_id].node == this_node.name:
|
if d_osd[osd_id] and d_osd[osd_id].node == this_node.name:
|
||||||
# Lock the command queue
|
# Lock the command queue
|
||||||
lock = zkhandler.writelock(zk_conn, '/ceph/cmd')
|
zk_lock = zkhandler.writelock(zk_conn, '/ceph/cmd')
|
||||||
with lock:
|
with zk_lock:
|
||||||
# Online the OSD
|
# Online the OSD
|
||||||
result = CephInstance.in_osd(zk_conn, logger, osd_id)
|
result = CephInstance.in_osd(zk_conn, logger, osd_id)
|
||||||
# Command succeeded
|
# Command succeeded
|
||||||
|
@ -745,8 +745,8 @@ def cmd(data, stat, event=''):
|
||||||
# Verify osd_id is in the list
|
# Verify osd_id is in the list
|
||||||
if d_osd[osd_id] and d_osd[osd_id].node == this_node.name:
|
if d_osd[osd_id] and d_osd[osd_id].node == this_node.name:
|
||||||
# Lock the command queue
|
# Lock the command queue
|
||||||
lock = zkhandler.writelock(zk_conn, '/ceph/cmd')
|
zk_lock = zkhandler.writelock(zk_conn, '/ceph/cmd')
|
||||||
with lock:
|
with zk_lock:
|
||||||
# Offline the OSD
|
# Offline the OSD
|
||||||
result = CephInstance.out_osd(zk_conn, logger, osd_id)
|
result = CephInstance.out_osd(zk_conn, logger, osd_id)
|
||||||
# Command succeeded
|
# Command succeeded
|
||||||
|
@ -765,8 +765,8 @@ def cmd(data, stat, event=''):
|
||||||
|
|
||||||
if this_node.router_state == 'primary':
|
if this_node.router_state == 'primary':
|
||||||
# Lock the command queue
|
# Lock the command queue
|
||||||
lock = zkhandler.writelock(zk_conn, '/ceph/cmd')
|
zk_lock = zkhandler.writelock(zk_conn, '/ceph/cmd')
|
||||||
with lock:
|
with zk_lock:
|
||||||
# Set the property
|
# Set the property
|
||||||
result = CephInstance.set_property(zk_conn, logger, option)
|
result = CephInstance.set_property(zk_conn, logger, option)
|
||||||
# Command succeeded
|
# Command succeeded
|
||||||
|
@ -785,8 +785,8 @@ def cmd(data, stat, event=''):
|
||||||
|
|
||||||
if this_node.router_state == 'primary':
|
if this_node.router_state == 'primary':
|
||||||
# Lock the command queue
|
# Lock the command queue
|
||||||
lock = zkhandler.writelock(zk_conn, '/ceph/cmd')
|
zk_lock = zkhandler.writelock(zk_conn, '/ceph/cmd')
|
||||||
with lock:
|
with zk_lock:
|
||||||
# Unset the property
|
# Unset the property
|
||||||
result = CephInstance.unset_property(zk_conn, logger, option)
|
result = CephInstance.unset_property(zk_conn, logger, option)
|
||||||
# Command succeeded
|
# Command succeeded
|
||||||
|
@ -805,8 +805,8 @@ def cmd(data, stat, event=''):
|
||||||
name, pgs = args.split(',')
|
name, pgs = args.split(',')
|
||||||
if this_node.router_state == 'primary':
|
if this_node.router_state == 'primary':
|
||||||
# Lock the command queue
|
# Lock the command queue
|
||||||
lock = zkhandler.writelock(zk_conn, '/ceph/cmd')
|
zk_lock = zkhandler.writelock(zk_conn, '/ceph/cmd')
|
||||||
with lock:
|
with zk_lock:
|
||||||
# Add the pool
|
# Add the pool
|
||||||
result = CephInstance.add_pool(zk_conn, logger, name, pgs)
|
result = CephInstance.add_pool(zk_conn, logger, name, pgs)
|
||||||
# Command succeeded
|
# Command succeeded
|
||||||
|
@ -825,8 +825,8 @@ def cmd(data, stat, event=''):
|
||||||
|
|
||||||
if this_node.router_state == 'primary':
|
if this_node.router_state == 'primary':
|
||||||
# Lock the command queue
|
# Lock the command queue
|
||||||
lock = zkhandler.writelock(zk_conn, '/ceph/cmd')
|
zk_lock = zkhandler.writelock(zk_conn, '/ceph/cmd')
|
||||||
with lock:
|
with zk_lock:
|
||||||
# Remove the pool
|
# Remove the pool
|
||||||
result = CephInstance.remove_pool(zk_conn, logger, name)
|
result = CephInstance.remove_pool(zk_conn, logger, name)
|
||||||
# Command succeeded
|
# Command succeeded
|
||||||
|
@ -1088,29 +1088,33 @@ def update_zookeeper():
|
||||||
# Close the Libvirt connection
|
# Close the Libvirt connection
|
||||||
lv_conn.close()
|
lv_conn.close()
|
||||||
|
|
||||||
# Update our local node lists
|
# Look for dead nodes and fence them
|
||||||
flushed_node_list = []
|
if config['daemon_mode'] == 'coordinator':
|
||||||
active_node_list = []
|
for node_name in d_node:
|
||||||
inactive_node_list = []
|
try:
|
||||||
for node_name in d_node:
|
node_daemon_state = zkhandler.readdata(zk_conn, '/nodes/{}/daemonstate'.format(node_name))
|
||||||
try:
|
node_domain_state = zkhandler.readdata(zk_conn, '/nodes/{}/domainstate'.format(node_name))
|
||||||
node_daemon_state = zkhandler.readdata(zk_conn, '/nodes/{}/daemonstate'.format(node_name))
|
node_keepalive = int(zkhandler.readdata(zk_conn, '/nodes/{}/keepalive'.format(node_name)))
|
||||||
node_domain_state = zkhandler.readdata(zk_conn, '/nodes/{}/domainstate'.format(node_name))
|
except:
|
||||||
node_keepalive = int(zkhandler.readdata(zk_conn, '/nodes/{}/keepalive'.format(node_name)))
|
node_daemon_state = 'unknown'
|
||||||
except:
|
node_domain_state = 'unknown'
|
||||||
node_daemon_state = 'unknown'
|
node_keepalive = 0
|
||||||
node_domain_state = 'unknown'
|
|
||||||
node_keepalive = 0
|
|
||||||
|
|
||||||
# Handle deadtime and fencng if needed
|
# Handle deadtime and fencng if needed
|
||||||
# (A node is considered dead when its keepalive timer is >6*keepalive_interval seconds
|
# (A node is considered dead when its keepalive timer is >6*keepalive_interval seconds
|
||||||
# out-of-date while in 'start' state)
|
# out-of-date while in 'start' state)
|
||||||
node_deadtime = int(time.time()) - ( int(config['keepalive_interval']) * int(config['fence_intervals']) )
|
node_deadtime = int(time.time()) - ( int(config['keepalive_interval']) * int(config['fence_intervals']) )
|
||||||
if node_keepalive < node_deadtime and node_daemon_state == 'run':
|
if node_keepalive < node_deadtime and node_daemon_state == 'run':
|
||||||
logger.out('Node {} seems dead - starting monitor for fencing'.format(node_name), state='w')
|
logger.out('Node {} seems dead - starting monitor for fencing'.format(node_name), state='w')
|
||||||
zkhandler.writedata(zk_conn, { '/nodes/{}/daemonstate'.format(node_name): 'dead' })
|
zk_lock = zkhandler.writelock(zk_conn, '/nodes/{}/daemonstate')
|
||||||
fence_thread = threading.Thread(target=fencing.fenceNode, args=(node_name, zk_conn, config, logger), kwargs={})
|
with zk_lock:
|
||||||
fence_thread.start()
|
# Ensures that, if we lost the lock race and come out of waiting,
|
||||||
|
# we won't try to trigger our own fence thread.
|
||||||
|
if zkhandler.readdata(zk_conn, '/nodes/{}/daemonstate') != 'dead':
|
||||||
|
fence_thread = threading.Thread(target=fencing.fenceNode, args=(node_name, zk_conn, config, logger), kwargs={})
|
||||||
|
fence_thread.start()
|
||||||
|
# Write the updated data after we start the fence thread
|
||||||
|
zkhandler.writedata(zk_conn, { '/nodes/{}/daemonstate'.format(node_name): 'dead' })
|
||||||
|
|
||||||
# Display node information to the terminal
|
# Display node information to the terminal
|
||||||
logger.out(
|
logger.out(
|
||||||
|
|
Loading…
Reference in New Issue