Change in vdsm[master]: virt: vmstats: do not report bogus stats values.

fromani at redhat.com fromani at redhat.com
Wed Feb 24 12:55:38 UTC 2016


Francesco Romani has uploaded a new change for review.

Change subject: virt: vmstats: do not report bogus stats values.
......................................................................

virt: vmstats: do not report bogus stats values.

If Vdsm detects some impossible values for the
just computed stats, it should not report them
to Engine, and log an error instead.

Change-Id: I5c402c954a732848b1a64f5d719c96778895ea2c
Related-To: https://bugzilla.redhat.com/1309884
Signed-off-by: Francesco Romani <fromani at redhat.com>
---
M vdsm/virt/vmstats.py
1 file changed, 29 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/66/53966/1

diff --git a/vdsm/virt/vmstats.py b/vdsm/virt/vmstats.py
index 11c7ff5..7d6d89d 100644
--- a/vdsm/virt/vmstats.py
+++ b/vdsm/virt/vmstats.py
@@ -129,13 +129,18 @@
 
         cpu_sys = ((last_sample['cpu.user'] - first_sample['cpu.user']) +
                    (last_sample['cpu.system'] - first_sample['cpu.system']))
-        stats['cpuSys'] = _usage_percentage(cpu_sys, interval)
+        if cpu_sys >= 0:
+            stats['cpuSys'] = _usage_percentage(cpu_sys, interval)
+        else:
+            logging.error('bogus value cpuSys=%i, ignored', cpu_sys)
 
         if all('cpu.time' in s for s in samples):
-            stats['cpuUser'] = _usage_percentage(
-                ((last_sample['cpu.time'] - first_sample['cpu.time']) -
-                 cpu_sys),
-                interval)
+            cpu_user = (
+                (last_sample['cpu.time'] - first_sample['cpu.time']) - cpu_sys)
+            if cpu_user >= 0:
+                stats['cpuUser'] = _usage_percentage(cpu_user, interval)
+            else:
+                logging.error('bogus value cpuUser=%i, ignored', cpu_user)
 
             return stats
 
@@ -162,6 +167,10 @@
         balloon_cur = 0
         with _skip_if_missing_stats(vm):
             balloon_cur = sample['balloon.current']
+            if balloon_cur < 0:
+                logging.error(
+                    'bogus value balloon_cur=%i, ignored', balloon_cur)
+                balloon_cur = 0
 
         stats['balloonInfo'].update({
             'balloon_max': str(max_mem),
@@ -182,7 +191,7 @@
         if vcpu_count != -1:
             stats['vcpuCount'] = vcpu_count
         else:
-            logging.error('Failed to get VM cpu count')
+            logging.error('bogus value vcpuCount=%i, ignored', vcpu_count)
 
 
 def _nic_traffic(vm_obj, name, model, mac,
@@ -332,7 +341,11 @@
             last_value = last_sample[last_key]
         except KeyError:
             continue
-        stats[name] = str((last_value - first_value) / interval)
+        rate = (last_value - first_value) / interval
+        if rate >= 0:
+            stats[name] = str(rate)
+        else:
+            logging.error('bogus value %s=%f, ignored', name, rate)
 
     return stats
 
@@ -353,7 +366,11 @@
         except KeyError:
             continue
         if operations:
-            stats[name] = str(elapsed_time / operations)
+            rate = elapsed_time / operations
+            if rate >= 0:
+                stats[name] = str(rate)
+            else:
+                logging.error('bogus value %s=%f, ignored', name, rate)
         else:
             stats[name] = '0'
 
@@ -372,7 +389,10 @@
             value = last_sample[key]
         except KeyError:
             continue
-        stats[name] = str(value)
+        if value >= 0:
+            stats[name] = str(value)
+        else:
+            logging.error('bogus value %s=%f, ignored', name, value)
 
     return stats
 


-- 
To view, visit https://gerrit.ovirt.org/53966
To unsubscribe, visit https://gerrit.ovirt.org/settings

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