Improve fencing migrate layout

Open the option to do this in parallel with some threads
This commit is contained in:
Joshua Boniface 2020-08-05 22:26:01 -04:00
parent 37b83aad6a
commit 02343079c0
1 changed files with 12 additions and 1 deletions

View File

@ -77,8 +77,15 @@ def fenceNode(node_name, zk_conn, config, logger):
# Migrate hosts away from a fenced node # Migrate hosts away from a fenced node
def migrateFromFencedNode(zk_conn, node_name, config, logger): def migrateFromFencedNode(zk_conn, node_name, config, logger):
logger.out('Migrating VMs from dead node "{}" to new hosts'.format(node_name), state='i') logger.out('Migrating VMs from dead node "{}" to new hosts'.format(node_name), state='i')
# Get the list of VMs
dead_node_running_domains = zkhandler.readdata(zk_conn, '/nodes/{}/runningdomains'.format(node_name)).split() dead_node_running_domains = zkhandler.readdata(zk_conn, '/nodes/{}/runningdomains'.format(node_name)).split()
for dom_uuid in dead_node_running_domains:
# Set the node to a custom domainstate so we know what's happening
zkhandler.writedata(zk_conn, { '/nodes/{}/domainstate'.format(node_name): 'fence-flush' })
# Migrate a VM after a flush
def fence_migrate_vm(dom_uuid):
VMInstance.flush_locks(zk_conn, logger, dom_uuid) VMInstance.flush_locks(zk_conn, logger, dom_uuid)
target_node = common.findTargetNode(zk_conn, config, dom_uuid) target_node = common.findTargetNode(zk_conn, config, dom_uuid)
@ -97,6 +104,10 @@ def migrateFromFencedNode(zk_conn, node_name, config, logger):
'/domains/{}/node_autostart'.format(dom_uuid): 'True' '/domains/{}/node_autostart'.format(dom_uuid): 'True'
}) })
# Loop through the VMs
for dom_uuid in dead_node_running_domains:
fence_migrate_vm(dom_uuid)
# Set node in flushed state for easy remigrating when it comes back # Set node in flushed state for easy remigrating when it comes back
zkhandler.writedata(zk_conn, { '/nodes/{}/domainstate'.format(node_name): 'flushed' }) zkhandler.writedata(zk_conn, { '/nodes/{}/domainstate'.format(node_name): 'flushed' })