Check if node changed during final check

Avoids situations where two migrates, to different nodes, happen in
rapid succession. Aborts the migration if the current target node no
longer matches what was set at the start of the execution.
This commit is contained in:
Joshua Boniface 2020-10-21 02:52:36 -04:00
parent 42514b9a50
commit 351076c15e
1 changed files with 6 additions and 0 deletions

View File

@ -353,6 +353,9 @@ class VMInstance(object):
self.inmigrate = True
self.logger.out('Migrating VM to node "{}"'.format(self.node), state='i', prefix='Domain {}'.format(self.domuuid))
# Used for sanity checking later
target_node = zkhandler.readdata(self.zk_conn, '/domains/{}/node'.format(self.domuuid))
aborted = False
def abort_migrate(reason):
@ -455,6 +458,9 @@ class VMInstance(object):
if self.node == self.lastnode or self.node == self.this_node.name:
abort_migrate('Target node matches the current active node during final check')
return
if self.node != target_node:
abort_migrate('Target node changed during preparation')
return
# A live migrate is attemped 3 times in succession
ticks = 0