Change in vdsm[master]: vmstats: Handle missing system_time and user_time
nsoffer at redhat.com
nsoffer at redhat.com
Wed May 13 06:58:54 UTC 2015
Nir Soffer has uploaded a new change for review.
Change subject: vmstats: Handle missing system_time and user_time
......................................................................
vmstats: Handle missing system_time and user_time
Since commit 9ba66c903083e (virt: Additional reporting of CPU usage in
ns) we are accessing keys which may be missing, causing:
GuestMonitor-test::ERROR::2015-05-13 09:26:31,998::vm::1341::
vm.Vm::(_getRunningVmStats)
vmId=`0386c369-d2b8-445a-8a7f-027458e6a734`::Error fetching vm stats
Traceback (most recent call last):
File "/usr/share/vdsm/virt/vm.py", line 1338, in _getRunningVmStats
vm_sample.interval)
File "/usr/share/vdsm/virt/vmstats.py", line 37, in produce
cpu(stats, first_sample, last_sample, interval)
File "/usr/share/vdsm/virt/vmstats.py", line 78, in cpu
stats['cpuUsage'] = str(last_sample['system_time']
KeyError: 'system_time'
Now we report 0 if system_time or user_time are missing.
Change-Id: Id26c427d67de47cbcc39ddd43ab4cfe8467432c4
Signed-off-by: Nir Soffer <nsoffer at redhat.com>
---
M vdsm/virt/vmstats.py
1 file changed, 6 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/45/40845/1
diff --git a/vdsm/virt/vmstats.py b/vdsm/virt/vmstats.py
index 4af8501..5cc7806 100644
--- a/vdsm/virt/vmstats.py
+++ b/vdsm/virt/vmstats.py
@@ -75,8 +75,12 @@
if first_sample is None or last_sample is None:
return
- stats['cpuUsage'] = str(last_sample['system_time']
- + last_sample['user_time'])
+ try:
+ stats['cpuUsage'] = str(last_sample['system_time'] +
+ last_sample['user_time'])
+ except KeyError:
+ stats['cpuUsage'] = '0'
+
try:
stats['cpuSys'] = _usage_percentage(
_diff(last_sample, first_sample, 'cpu.user') +
--
To view, visit https://gerrit.ovirt.org/40845
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id26c427d67de47cbcc39ddd43ab4cfe8467432c4
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer at redhat.com>
More information about the vdsm-patches
mailing list