Remove additional wait and add last_node entries

These allow for aborting a migration to retain the previous settings and
override what the client set.
This commit is contained in:
Joshua Boniface 2020-10-20 15:55:44 -04:00
parent 442aa4e420
commit 11fa3b0df3
1 changed files with 6 additions and 3 deletions

View File

@ -108,6 +108,8 @@ class VMInstance(object):
self.state = zkhandler.readdata(self.zk_conn, '/domains/{}/state'.format(self.domuuid)) self.state = zkhandler.readdata(self.zk_conn, '/domains/{}/state'.format(self.domuuid))
self.node = zkhandler.readdata(self.zk_conn, '/domains/{}/node'.format(self.domuuid)) self.node = zkhandler.readdata(self.zk_conn, '/domains/{}/node'.format(self.domuuid))
self.lastnode = zkhandler.readdata(self.zk_conn, '/domains/{}/lastnode'.format(self.domuuid)) self.lastnode = zkhandler.readdata(self.zk_conn, '/domains/{}/lastnode'.format(self.domuuid))
self.last_currentnode = zkhandler.readdata(self.zk_conn, '/domains/{}/node'.format(self.domuuid))
self.last_lastnode = zkhandler.readdata(self.zk_conn, '/domains/{}/lastnode'.format(self.domuuid))
try: try:
self.pinpolicy = zkhandler.readdata(self.zk_conn, '/domains/{}/pinpolicy'.format(self.domuuid)) self.pinpolicy = zkhandler.readdata(self.zk_conn, '/domains/{}/pinpolicy'.format(self.domuuid))
except: except:
@ -359,7 +361,6 @@ class VMInstance(object):
self.logger.out('Queueing for completion of existing migration', state='i', prefix='Domain {}'.format(self.domuuid)) self.logger.out('Queueing for completion of existing migration', state='i', prefix='Domain {}'.format(self.domuuid))
while zkhandler.readdata(self.zk_conn, '/locks/domain_migrate') != '': while zkhandler.readdata(self.zk_conn, '/locks/domain_migrate') != '':
time.sleep(0.1) time.sleep(0.1)
time.sleep(0.2)
self.inmigrate = True self.inmigrate = True
self.logger.out('Migrating VM to node "{}"'.format(self.node), state='i', prefix='Domain {}'.format(self.domuuid)) self.logger.out('Migrating VM to node "{}"'.format(self.node), state='i', prefix='Domain {}'.format(self.domuuid))
@ -370,7 +371,7 @@ class VMInstance(object):
zkhandler.writedata(self.zk_conn, { zkhandler.writedata(self.zk_conn, {
'/domains/{}/state'.format(self.domuuid): 'start', '/domains/{}/state'.format(self.domuuid): 'start',
'/domains/{}/node'.format(self.domuuid): self.this_node.name, '/domains/{}/node'.format(self.domuuid): self.this_node.name,
'/domains/{}/lastnode'.format(self.domuuid): '' '/domains/{}/lastnode'.format(self.domuuid): self.last_lastnode
}) })
# Acquire exclusive lock on the domain node key # Acquire exclusive lock on the domain node key
@ -440,6 +441,9 @@ class VMInstance(object):
self.console_log_instance.stop() self.console_log_instance.stop()
self.removeDomainFromList() self.removeDomainFromList()
self.last_currentnode = zkhandler.readdata(self.zk_conn, '/domains/{}/node'.format(self.domuuid))
self.last_lastnode = zkhandler.readdata(self.zk_conn, '/domains/{}/lastnode'.format(self.domuuid))
return True return True
def migrate_shutdown(): def migrate_shutdown():
@ -523,7 +527,6 @@ class VMInstance(object):
self.logger.out('Queueing for completion of existing migration', state='i', prefix='Domain {}'.format(self.domuuid)) self.logger.out('Queueing for completion of existing migration', state='i', prefix='Domain {}'.format(self.domuuid))
while zkhandler.readdata(self.zk_conn, '/locks/domain_migrate') != '': while zkhandler.readdata(self.zk_conn, '/locks/domain_migrate') != '':
time.sleep(0.1) time.sleep(0.1)
time.sleep(0.5)
self.inreceive = True self.inreceive = True
live_receive = True live_receive = True