From 6d779a811b33f70e456d415aa58d51aac5d7b9d9 Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Tue, 17 Jul 2018 00:25:36 -0400 Subject: [PATCH] Add wait time between flush migrates Adds a wait timer between each VM migration during a flush action, based on the state of the target VM. This causes each state change command to wait until the last VM has completed its migration, preventing all a node's VMs from being migrated to the same "least RAM" hypervisor at once before any start to migrate. Fixes #6 --- pvcd/NodeInstance.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pvcd/NodeInstance.py b/pvcd/NodeInstance.py index 259ec9e7..8ae59a31 100644 --- a/pvcd/NodeInstance.py +++ b/pvcd/NodeInstance.py @@ -161,6 +161,13 @@ class NodeInstance(): '/domains/{}/lasthypervisor'.format(dom_uuid): current_hypervisor }) + # Wait for the VM to migrate so the next VM's free RAM count is accurate (they migrate in serial anyways) + while True: + time.sleep(1) + vm_current_state = zkhandler.readdata(self.zk_conn, '/domains/{}/state'.format(domuuid)) + 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' }) self.inflush = False