Change in vdsm[ovirt-3.6]: virt: stats: make disk_rate 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/53995
to review the following change.
Change subject: virt: stats: make disk_rate more robust
......................................................................
virt: stats: make disk_rate more robust
Bulk stats can return any subset of keys.
Previously, we had too weak protection, leading
to some KeyError peppering up the logs, for example
when storage was slow to respond.
Now we add more careful protection for disk_rate.
Following patches will fix the other code accessing
storage stats.
Change-Id: Ib2900e73161932f7fbecd9d7bfaba36dc1e84e19
Backport-To: 3.6
Bug-Url: https://bugzilla.redhat.com/1281337
Signed-off-by: Francesco Romani <fromani at redhat.com>
Reviewed-on: https://gerrit.ovirt.org/48493
Reviewed-by: Martin Polednik <mpolednik at redhat.com>
Continuous-Integration: Jenkins CI
Reviewed-by: Nir Soffer <nsoffer at redhat.com>
---
M vdsm/virt/vmstats.py
1 file changed, 13 insertions(+), 10 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/95/53995/1
diff --git a/vdsm/virt/vmstats.py b/vdsm/virt/vmstats.py
index 93dd0e3..7987cae 100644
--- a/vdsm/virt/vmstats.py
+++ b/vdsm/virt/vmstats.py
@@ -308,16 +308,19 @@
def _disk_rate(first_sample, first_index, last_sample, last_index, interval):
- return {
- 'readRate': str(
- (last_sample['block.%d.rd.bytes' % last_index] -
- first_sample['block.%d.rd.bytes' % first_index])
- / interval),
- 'writeRate': str(
- (last_sample['block.%d.wr.bytes' % last_index] -
- first_sample['block.%d.wr.bytes' % first_index])
- / interval)
- }
+ stats = {}
+
+ for name, mode in (("readRate", "rd"), ("writeRate", "wr")):
+ first_key = 'block.%d.%s.bytes' % (first_index, mode)
+ last_key = 'block.%d.%s.bytes' % (last_index, mode)
+ try:
+ first_value = first_sample[first_key]
+ last_value = last_sample[last_key]
+ except KeyError:
+ continue
+ stats[name] = str((last_value - first_value) / interval)
+
+ return stats
def _disk_latency(first_sample, first_index, last_sample, last_index):
--
To view, visit https://gerrit.ovirt.org/53995
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib2900e73161932f7fbecd9d7bfaba36dc1e84e19
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