Change in vdsm[ovirt-3.6]: virt: stats: make compute_latency more robust
fromani at redhat.com
fromani at redhat.com
Wed Feb 24 15:28:10 UTC 2016
Hello Nir Soffer, Martin Polednik,
I'd like you to do a code review. Please visit
https://gerrit.ovirt.org/53996
to review the following change.
Change subject: virt: stats: make compute_latency more robust
......................................................................
virt: stats: make compute_latency more robust
Make compute_latency more robust and less noisy
when some fields are missing from bulk stats.
This can happen, so we must handle this case silently.
Backport-To: 3.6
Bug-Url: https://bugzilla.redhat.com/1281337
Change-Id: Ie4670309d48bd65a3afaba8124407598b76d808d
Signed-off-by: Francesco Romani <fromani at redhat.com>
Reviewed-on: https://gerrit.ovirt.org/50593
Continuous-Integration: Jenkins CI
Reviewed-by: Martin Polednik <mpolednik at redhat.com>
Reviewed-by: Nir Soffer <nsoffer at redhat.com>
---
M vdsm/virt/vmstats.py
1 file changed, 19 insertions(+), 15 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/96/53996/1
diff --git a/vdsm/virt/vmstats.py b/vdsm/virt/vmstats.py
index 7987cae..f29d195 100644
--- a/vdsm/virt/vmstats.py
+++ b/vdsm/virt/vmstats.py
@@ -324,22 +324,26 @@
def _disk_latency(first_sample, first_index, last_sample, last_index):
- def compute_latency(ltype):
- operations = (
- last_sample['block.%d.%s.reqs' % (last_index, ltype)] -
- first_sample['block.%d.%s.reqs' % (first_index, ltype)]
- )
- if not operations:
- return 0
- elapsed_time = (
- last_sample['block.%d.%s.times' % (last_index, ltype)] -
- first_sample['block.%d.%s.times' % (first_index, ltype)]
- )
- return elapsed_time / operations
+ stats = {}
- return {'readLatency': str(compute_latency('rd')),
- 'writeLatency': str(compute_latency('wr')),
- 'flushLatency': str(compute_latency('fl'))}
+ for name, mode in (('readLatency', 'rd'),
+ ('writeLatency', 'wr'),
+ ('flushLatency', 'fl')):
+ try:
+ last_key = "block.%d.%s" % (last_index, mode)
+ first_key = "block.%d.%s" % (first_index, mode)
+ operations = (last_sample[last_key + ".reqs"] -
+ first_sample[first_key + ".reqs"])
+ elapsed_time = (last_sample[last_key + ".times"] -
+ first_sample[first_key + ".times"])
+ except KeyError:
+ continue
+ if operations:
+ stats[name] = str(elapsed_time / operations)
+ else:
+ stats[name] = '0'
+
+ return stats
def _disk_iops_bytes(first_sample, first_index, last_sample, last_index):
--
To view, visit https://gerrit.ovirt.org/53996
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie4670309d48bd65a3afaba8124407598b76d808d
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.6
Gerrit-Owner: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Martin Polednik <mpolednik at redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
More information about the vdsm-patches
mailing list