Fix bugs with fencing
This commit is contained in:
parent
7df200ac44
commit
ad284b13bc
|
@ -77,29 +77,32 @@ def migrateFromFencedNode(zk_conn, node_name, logger):
|
|||
logger.out('Moving VMs from dead node "{}" to new hosts'.format(node_name), state='i')
|
||||
dead_node_running_domains = zkhandler.readdata(zk_conn, '/nodes/{}/runningdomains'.format(node_name)).split()
|
||||
for dom_uuid in dead_node_running_domains:
|
||||
target_node = findTargetHypervisor(zk_conn, 'mem', dom_uuid)
|
||||
|
||||
logger.out('Flushing RBD locks for VM "{}"'.format(dom_uuid), state='i')
|
||||
# Get the list of RBD images
|
||||
rbd_list = zkhandler.readdata(zk_conn, '/domains/{}/rbdlist'.format(dom_uuid)).split(',')
|
||||
for rbd in rbd_list:
|
||||
# Check if a lock exists
|
||||
retcode, stdout, stderr = common.run_os_command('rbd lock list --format json {}'.format(rbd))
|
||||
if not retcode:
|
||||
lock_list_retcode, lock_list_stdout, lock_list_stderr = common.run_os_command('rbd lock list --format json {}'.format(rbd))
|
||||
if lock_list_retcode != 0:
|
||||
logger.out('Failed to obtain lock list for volume "{}"'.format(rbd), state='e')
|
||||
continue
|
||||
lock_list = stdout
|
||||
try:
|
||||
lock_list = json.loads(lock_list_stdout)
|
||||
except:
|
||||
lock_list = {}
|
||||
|
||||
# If there's at least one lock
|
||||
if lock_list:
|
||||
# Loop through the locks
|
||||
for lock, detail in lock_list.items():
|
||||
# Free the lock
|
||||
retcode, stdout, stderr = common.run_os_command('rbd lock remove {} "{}" "{}"'.format(rbd, lock, detail['locker']))
|
||||
if not retcode:
|
||||
lock_remove_retcode, lock_remove_stdout, lock_remove_stderr = common.run_os_command('rbd lock remove {} "{}" "{}"'.format(rbd, lock, detail['locker']))
|
||||
if lock_remove_retcode != 0:
|
||||
logger.out('Failed to free RBD lock "{}" on volume "{}"'.format(lock, rbd), state='e')
|
||||
continue
|
||||
logger.out('Freed RBD lock "{}" on volume "{}"'.format(lock, rbd), state='o')
|
||||
|
||||
target_node = common.findTargetHypervisor(zk_conn, 'mem', dom_uuid)
|
||||
|
||||
logger.out('Migrating VM "{}" to node "{}"'.format(dom_uuid, target_node), state='i')
|
||||
zkhandler.writedata(zk_conn, {
|
||||
|
|
Loading…
Reference in New Issue