Handle unflushes like flushes squentially

Makes an unflush a controlled event like flushing, rather than a
free-for-all. This does slow down unflushing somewhat (disallowing
parallelism from multiple hosts to the current host), but allows
the locking to actually be effective.
This commit is contained in:
Joshua Boniface 2019-05-11 00:30:47 -04:00
parent 91ea96b772
commit 516ea1b57c
1 changed files with 8 additions and 5 deletions

View File

@ -140,7 +140,9 @@ class NodeInstance(object):
flush_thread = threading.Thread(target=self.flush, args=(), kwargs={})
flush_thread.start()
if self.domain_state == 'unflush' and self.inflush == False:
self.unflush()
# Do unflushing in a thread so it doesn't block the migrates in
flush_thread = threading.Thread(target=self.unflush, args=(), kwargs={})
flush_thread.start()
@self.zk_conn.DataWatch('/nodes/{}/memfree'.format(self.name))
def watch_node_memfree(data, stat, event=''):
@ -348,11 +350,8 @@ class NodeInstance(object):
})
# Wait for the VM to migrate so the next VM's free RAM count is accurate (they migrate in serial anyways)
while True:
while zkhandler.readdata(self.zk_conn, '/domains/{}/state'.format(dom_uuid)) != 'start':
time.sleep(1)
vm_current_state = zkhandler.readdata(self.zk_conn, '/domains/{}/state'.format(dom_uuid))
if vm_current_state == "start":
break
zkhandler.writedata(self.zk_conn, { '/nodes/{}/runningdomains'.format(self.name): '' })
zkhandler.writedata(self.zk_conn, { '/nodes/{}/domainstate'.format(self.name): 'flushed' })
@ -394,6 +393,10 @@ class NodeInstance(object):
'/domains/{}/lastnode'.format(dom_uuid): ''
})
# Wait for the VM to migrate back
while zkhandler.readdata(self.zk_conn, '/domains/{}/state'.format(dom_uuid)) != 'start':
time.sleep(1)
self.inflush = False
# Release the flush lock