Change in vdsm[ovirt-3.5]: sampling: do not produce stats for missing disks

fromani at redhat.com fromani at redhat.com
Wed Sep 10 10:58:39 UTC 2014


Hello Nir Soffer, Dan Kenigsberg,

I'd like you to do a code review.  Please visit

    http://gerrit.ovirt.org/32749

to review the following change.

Change subject: sampling: do not produce stats for missing disks
......................................................................

sampling: do not produce stats for missing disks

Adding of a new disk using hotplug (hotplugDisk verb)
can trigger an error during the stats reporting (getVmStats verb).
This error is transient, so it was likely got unnoticed so far.

When a disk is hot-plugged, VDSM correctly updates the list
of the drives of a VM.
When stats for such a VM are asked, VDSM iterates over the list of
the drives of a VM, and  looks up for disk samples of each drive.
The stats are collected (by default) every 60s, and VDSM considers
the oldest and the newest samples; so, until the oldest set of
samples collected includes values for the hotplugged disk,
we will have an error.

We have a vulerabilility window up to
(sampling_window * sampling_interval)
in the worst case. With default values this is 2 * 60s = 120s.
After that, everything goes back to normality, and the
stats for the new disk are reported correctly.

This patch fixes this issue by just ignoring stats for disks
which are part of a VM, but for which samples aren't
yet available.

Change-Id: If93572c21ecd47fe0bb2a6c6e13c0555034be881
Bug-Url: https://bugzilla.redhat.com/1119051
Signed-off-by: Francesco Romani <fromani at redhat.com>
Reviewed-on: http://gerrit.ovirt.org/30029
Reviewed-by: Nir Soffer <nsoffer at redhat.com>
Reviewed-by: Dan Kenigsberg <danken at redhat.com>
---
M vdsm/virt/vm.py
1 file changed, 7 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/49/32749/1

diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 91b7400..7d2f98c 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -544,13 +544,14 @@
                     dStats['imageID'] = vmDrive.imageID
                 elif "GUID" in vmDrive:
                     dStats['lunGUID'] = vmDrive.GUID
-                if sInfo is not None:
+                if sInfo is not None and (
+                        vmDrive.name in sInfo and vmDrive.name in eInfo):
                     # will be None if sampled during recovery
                     dStats['readRate'] = (
                         (eInfo[dName][1] - sInfo[dName][1]) / sampleInterval)
                     dStats['writeRate'] = (
                         (eInfo[dName][3] - sInfo[dName][3]) / sampleInterval)
-            except (AttributeError, KeyError, TypeError, ZeroDivisionError):
+            except (AttributeError, TypeError, ZeroDivisionError):
                 self._log.exception("Disk %s stats not available", dName)
 
             stats[dName] = dStats
@@ -588,11 +589,13 @@
                         'writeLatency': '0',
                         'flushLatency': '0'}
 
-            if sInfo is not None:
+            if sInfo is not None and (dName in sInfo and dName in eInfo):
                 # will be None if sampled during recovery
+                # in case of hotplugged disk, start samples will
+                # be missed until the sampling code catches up.
                 try:
                     dLatency = _avgLatencyCalc(sInfo[dName], eInfo[dName])
-                except (KeyError, TypeError):
+                except TypeError:
                     self._log.warning("Disk %s latency not available", dName)
 
             stats[dName].update(dLatency)


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If93572c21ecd47fe0bb2a6c6e13c0555034be881
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>


More information about the vdsm-patches mailing list