Change in vdsm[master]: virt: stats: explicitily handle not enough samples
fromani at redhat.com
fromani at redhat.com
Tue Apr 15 14:36:40 UTC 2014
Francesco Romani has uploaded a new change for review.
Change subject: virt: stats: explicitily handle not enough samples
......................................................................
virt: stats: explicitily handle not enough samples
sampling code needs a miniumum amount of samples
to do its job.
this patch adds explicit handling of this condition
through a new exception.
Change-Id: I6d5d908b46b6968555b10380d081aebe24d8645f
Signed-off-by: Francesco Romani <fromani at redhat.com>
---
M vdsm/virt/sampling.py
M vdsm/virt/vm.py
2 files changed, 22 insertions(+), 8 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/91/26791/1
diff --git a/vdsm/virt/sampling.py b/vdsm/virt/sampling.py
index 991c969..389bb65 100644
--- a/vdsm/virt/sampling.py
+++ b/vdsm/virt/sampling.py
@@ -196,6 +196,10 @@
self.thpState = 'never'
+class NotEnoughSamplesError(Exception):
+ pass
+
+
class AdvancedStatsFunction(object):
"""
A wrapper for functions and methods that will be executed at regular
@@ -239,7 +243,7 @@
time difference.
"""
if len(self._sample) < 2:
- return None, None, None
+ raise NotEnoughSamplesError
bgn_time, bgn_sample = self._sample[0]
end_time, end_sample = self._sample[-1]
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index d8112ad..42025c0 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -231,7 +231,8 @@
# Avoid queries from storage during recovery process
if self._vm.isDisksStatsCollectionEnabled():
for vmDrive in self._vm._devices[DISK_DEVICES]:
- diskSamples[vmDrive.name] = self._vm._dom.blockStats(vmDrive.name)
+ diskSamples[vmDrive.name] = self._vm._dom.blockStats(
+ vmDrive.name)
return diskSamples
def _sampleDiskLatency(self):
@@ -260,7 +261,10 @@
return 100 * val / sampleInterval / 1000 ** 3
def _getCpuStats(self, stats):
- sInfo, eInfo, sampleInterval = self.sampleCpu.getStats()
+ try:
+ sInfo, eInfo, sampleInterval = self.sampleCpu.getStats()
+ except sampling.NotEnoughSamplesError:
+ return
try:
stats['cpuSys'] = self._usagePercentage(
@@ -307,9 +311,9 @@
def _getNetworkStats(self, stats):
stats['network'] = {}
- sInfo, eInfo, sampleInterval = self.sampleNet.getStats()
-
- if sInfo is None:
+ try:
+ sInfo, eInfo, sampleInterval = self.sampleNet.getStats()
+ except sampling.NotEnoughSamplesError:
return
for nic in self._vm._devices[NIC_DEVICES]:
@@ -325,7 +329,10 @@
sInfo[nic.name], eInfo[nic.name], sampleInterval)
def _getDiskStats(self, stats):
- sInfo, eInfo, sampleInterval = self.sampleDisk.getStats()
+ try:
+ sInfo, eInfo, sampleInterval = self.sampleDisk.getStats()
+ except sampling.NotEnoughSamplesError:
+ return
for vmDrive in self._vm._devices[DISK_DEVICES]:
dName = vmDrive.name
@@ -347,7 +354,10 @@
stats[dName] = dStats
def _getDiskLatency(self, stats):
- sInfo, eInfo, sampleInterval = self.sampleDiskLatency.getStats()
+ try:
+ sInfo, eInfo, sampleInterval = self.sampleDiskLatency.getStats()
+ except sampling.NotEnoughSamplesError:
+ return
def _avgLatencyCalc(sData, eData):
readLatency = (0 if not (eData['rd_operations'] -
--
To view, visit http://gerrit.ovirt.org/26791
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6d5d908b46b6968555b10380d081aebe24d8645f
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