Thread the flush function

Prevents a bug where the flush function blocks receiving migrations
This commit is contained in:
Joshua Boniface 2018-07-17 01:04:35 -04:00
parent a6bdc281a2
commit 1dbe0d64ba
1 changed files with 3 additions and 2 deletions

View File

@ -64,11 +64,12 @@ class NodeInstance():
# toggle state management of this node # toggle state management of this node
if self.name == self.this_node: if self.name == self.this_node:
if self.domain_state == 'flush' and self.inflush == False: if self.domain_state == 'flush' and self.inflush == False:
self.flush() # Do flushing in a thread so it doesn't block the migrates out
flush_thread = threading.Thread(target=flush, args=(self), kwargs={})
flush_thread.start()
if self.domain_state == 'unflush' and self.inflush == False: if self.domain_state == 'unflush' and self.inflush == False:
self.unflush() self.unflush()
@zk_conn.DataWatch('/nodes/{}/memfree'.format(self.name)) @zk_conn.DataWatch('/nodes/{}/memfree'.format(self.name))
def watch_hypervisor_memfree(data, stat, event=""): def watch_hypervisor_memfree(data, stat, event=""):
try: try: