Change in vdsm[master]: vm: bootstrap services using updateVolume

fromani at redhat.com fromani at redhat.com
Mon Feb 9 08:53:21 UTC 2015


Francesco Romani has uploaded a new change for review.

Change subject: vm: bootstrap services using updateVolume
......................................................................

vm: bootstrap services using updateVolume

During their lifetime the volumes of a VM needs
to be updated. This is a task carried by the
'updateVolumes' operation, which was formerly
piggybacked in the sampling threads.

But actually 'updateVolumes' is a perfect candidate
to motivy the need of a 'services' infrastructure to
run periodic (bookkeeping) tasks for VMs.

So, this patch bootstraps the usage of the newly
added services infrastructure by moving 'updateVolumes'
from sampling threads to 'services'.

No changes in behaviour are meant.

Change-Id: Idf5f4bff03acf4fb43eb6d296e4c02a6b7a52baa
Signed-off-by: Francesco Romani <fromani at redhat.com>
---
M vdsm/virt/services.py
M vdsm/virt/vm.py
2 files changed, 19 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/94/37594/1

diff --git a/vdsm/virt/services.py b/vdsm/virt/services.py
index dcb83a8..5bd4225 100644
--- a/vdsm/virt/services.py
+++ b/vdsm/virt/services.py
@@ -27,6 +27,7 @@
 
 from vdsm import executor
 from vdsm import schedule
+from vdsm.config import config
 from vdsm.utils import monotonic_time
 
 
@@ -55,7 +56,10 @@
         exc.start()
         _executor = exc
 
-    _calls = []
+    _calls = [
+        RepeatingCall(UpdateVolumes(cif),
+                      config.getint('irs', 'vol_size_sample_interval'))]
+
     for call in _calls:
         call.start()
 
@@ -133,3 +137,16 @@
             if self._running:
                 self._call = None
                 self._executor.dispatch(self, self._timeout)
+
+
+class UpdateVolumes(object):
+    def __init__(self, cif):
+        self._cif = cif
+
+    def __call__(self):
+        vms = self._cif.getVMs()
+        for vmId, vmObj in vms.iteritems():
+            if vmObj.isDisksStatsCollectionEnabled():
+                # Avoid queries from storage during recovery process
+                for vmDrive in vmObj.getDiskDevices():
+                    vmObj.updateDriveVolume(vmDrive)
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 3a61f04..ddc852d 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -189,10 +189,6 @@
             AdvancedStatsFunction(
                 self._highWrite,
                 config.getint('vars', 'vm_watermark_interval')))
-        self.updateVolumes = (
-            AdvancedStatsFunction(
-                self._updateVolumes,
-                config.getint('irs', 'vol_size_sample_interval')))
 
         self.sampleCpu = (
             AdvancedStatsFunction(
@@ -227,7 +223,7 @@
                 config.getint('vars', 'vm_sample_cpu_tune_interval'), 1))
 
         self.addStatsFunction(
-            self.highWrite, self.updateVolumes, self.sampleCpu,
+            self.highWrite, self.sampleCpu,
             self.sampleDisk, self.sampleNet, self.sampleBalloon,
             self.sampleVmJobs, self.sampleVcpuPinning, self.sampleCpuTune)
 
@@ -236,14 +232,6 @@
             # Avoid queries from storage during recovery process
             return
         self._vm.extendDrivesIfNeeded()
-
-    def _updateVolumes(self):
-        if not self._vm.isDisksStatsCollectionEnabled():
-            # Avoid queries from storage during recovery process
-            return
-
-        for vmDrive in self._vm.getDiskDevices():
-            self._vm.updateDriveVolume(vmDrive)
 
     def _sampleCpu(self):
         """


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idf5f4bff03acf4fb43eb6d296e4c02a6b7a52baa
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