Change in vdsm[master]: stats: not log when cpu stats are known missing

fromani at redhat.com fromani at redhat.com
Tue May 6 13:14:22 UTC 2014


Francesco Romani has uploaded a new change for review.

Change subject: stats: not log when cpu stats are known missing
......................................................................

stats: not log when cpu stats are known missing

There are some known cases on which the cpu stats cannot
be available, for example if not enough samples are yet
collected.

Those cases are already handled by the current code,
but their treatment is mixed with the handling of truly
exceptional cases, while the aforementioned cases are
expected errors, thus not 'exceptional' errors.

This patch add explicit handling for the missing cpu
stats case, to avoid to produce log noise when it is
expected to not have the cpu stats.

Change-Id: I62eff2e04a2922fb683d3c1d78605990399c7b76
Signed-off-by: Francesco Romani <fromani at redhat.com>
---
M vdsm/virt/vm.py
1 file changed, 6 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/16/27416/1

diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 2b4c023..7fc4932 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -264,7 +264,13 @@
         return 100 * val / sampleInterval / 1000 ** 3
 
     def _getCpuStats(self, stats):
+        stats['cpuUser'] = 0.0
+        stats['cpuSys'] = 0.0
+
         sInfo, eInfo, sampleInterval = self.sampleCpu.getStats()
+
+        if sInfo is None:
+            return
 
         try:
             stats['cpuSys'] = self._usagePercentage(
@@ -279,8 +285,6 @@
 
         except (TypeError, ZeroDivisionError) as e:
             self._log.debug("CPU stats not available: %s", e)
-            stats['cpuUser'] = 0.0
-            stats['cpuSys'] = 0.0
 
     @classmethod
     def _getNicStats(cls, name, model, mac,


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

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