Change in vdsm[master]: vm: migration: move wait countdown in a function

fromani at redhat.com fromani at redhat.com
Tue Sep 9 15:26:02 UTC 2014


Francesco Romani has uploaded a new change for review.

Change subject: vm: migration: move  wait countdown in a function
......................................................................

vm: migration: move  wait countdown in a function

The Downtime thread is a migration helper thread
which is in charge of periodically updating the
migration downtime.

This thread blindly does a configurabile number
of steps, and after each step it updates the
downtime according to a given law.

Between each step, it waits for a number of
seconds according to a different law.

Both the cases on which migration ends while
downtime thread is running and after it
is ended are implicitely and gracefully
handled by the existing code, since it
is safe to set the downtime aynchronously.

The downtime update law was already extracted;
this patch also extracts the wait law,
in order to improve readability and testability.

Change-Id: Id808539a654e1556519ed54f6f4b67364eacf48a
Signed-off-by: Francesco Romani <fromani at redhat.com>
---
M vdsm/virt/migration.py
1 file changed, 15 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/06/32706/1

diff --git a/vdsm/virt/migration.py b/vdsm/virt/migration.py
index 836fe3c..97333ca 100644
--- a/vdsm/virt/migration.py
+++ b/vdsm/virt/migration.py
@@ -362,8 +362,17 @@
         yield offset + int(base ** i)
 
 
+def linear_wait(mem_size, delay, steps):
+    wait = (delay * max(mem_size, 2048) + 1023) / 1024
+
+    for _ in range(steps):
+        yield wait / steps
+
+
 class DowntimeThread(threading.Thread):
     DOWNTIME_STEPS = config.getint('vars', 'migration_downtime_steps')
+
+    DELAY_PER_GIB = config.getint('vars', 'migration_downtime_delay')
 
     def __init__(self, vm, downtime):
         super(DowntimeThread, self).__init__()
@@ -373,19 +382,18 @@
 
         self._stop = threading.Event()
 
-        delay_per_gib = config.getint('vars', 'migration_downtime_delay')
-        mem_size = int(self._vm.conf['memSize'])
-        self._wait = (delay_per_gib * max(mem_size, 2048) + 1023) / 1024
-
         self.daemon = True
         self.start()
 
     def run(self):
         self._vm.log.debug('migration downtime thread started')
 
-        for downtime in exponential_downtime(self._downtime,
-                                             self.DOWNTIME_STEPS):
-            self._stop.wait(self._wait / self.DOWNTIME_STEPS)
+        for downtime, wait in zip(exponential_downtime(self._downtime,
+                                                       self.DOWNTIME_STEPS),
+                                  linear_wait(int(self._vm.conf['memSize']),
+                                              self.DELAY_PER_GIB,
+                                              self.DOWNTIME_STEPS)):
+            self._stop.wait(wait)
 
             if self._stop.isSet():
                 break


-- 
To view, visit http://gerrit.ovirt.org/32706
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id808539a654e1556519ed54f6f4b67364eacf48a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani at redhat.com>


More information about the vdsm-patches mailing list