Improve flush handling
Similar to recent client changes, don't replace the previous node record of an already-migrated VM. Wait for shutdown if required. Use a continue statement instead of a needless else block.
This commit is contained in:
parent
0d398f663b
commit
b82ccaa84d
|
@ -359,12 +359,24 @@ class NodeInstance(object):
|
||||||
for dom_uuid in fixed_domain_list:
|
for dom_uuid in fixed_domain_list:
|
||||||
self.logger.out('Selecting target to migrate VM "{}"'.format(dom_uuid), state='i')
|
self.logger.out('Selecting target to migrate VM "{}"'.format(dom_uuid), state='i')
|
||||||
|
|
||||||
current_node = zkhandler.readdata(self.zk_conn, '/domains/{}/node'.format(dom_uuid))
|
|
||||||
target_node = findTargetHypervisor(self.zk_conn, 'mem', dom_uuid)
|
target_node = findTargetHypervisor(self.zk_conn, 'mem', dom_uuid)
|
||||||
|
|
||||||
|
# Don't replace the previous node if the VM is already migrated
|
||||||
|
if zkhandler.readdata(self.zk_conn, '/domains/{}/migrated') is 'yes':
|
||||||
|
current_node = zkhandler.readdata(self.zk_conn, '/domains/{}/lastnode')
|
||||||
|
else:
|
||||||
|
current_node = zkhandler.readdata(self.zk_conn, '/domains/{}/node'.format(dom_uuid))
|
||||||
|
|
||||||
if target_node == None:
|
if target_node == None:
|
||||||
self.logger.out('Failed to find migration target for VM "{}"; shutting down'.format(dom_uuid), state='e')
|
self.logger.out('Failed to find migration target for VM "{}"; shutting down'.format(dom_uuid), state='e')
|
||||||
zkhandler.writedata(self.zk_conn, { '/domains/{}/state'.format(dom_uuid): 'shutdown' })
|
zkhandler.writedata(self.zk_conn, { '/domains/{}/state'.format(dom_uuid): 'shutdown' })
|
||||||
else:
|
|
||||||
|
# Wait for the VM to shut down
|
||||||
|
while zkhandler.readdata(self.zk_conn, '/domains/{}/state'.format(dom_uuid)) != 'stop':
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
continue
|
||||||
|
|
||||||
self.logger.out('Migrating VM "{}" to node "{}"'.format(dom_uuid, target_node), state='i')
|
self.logger.out('Migrating VM "{}" to node "{}"'.format(dom_uuid, target_node), state='i')
|
||||||
zkhandler.writedata(self.zk_conn, {
|
zkhandler.writedata(self.zk_conn, {
|
||||||
'/domains/{}/state'.format(dom_uuid): 'migrate',
|
'/domains/{}/state'.format(dom_uuid): 'migrate',
|
||||||
|
|
Loading…
Reference in New Issue