Change in vdsm[master]: virt: sampling: more cautious disk stats check

nsoffer at redhat.com nsoffer at redhat.com
Mon Sep 29 15:32:35 UTC 2014


Nir Soffer has posted comments on this change.

Change subject: virt: sampling: more cautious disk stats check
......................................................................


Patch Set 1:

(2 comments)

http://gerrit.ovirt.org/#/c/33482/1/vdsm/virt/vm.py
File vdsm/virt/vm.py:

Line 538:                 if isVdsmImage(vmDrive):
Line 539:                     dStats['imageID'] = vmDrive.imageID
Line 540:                 elif "GUID" in vmDrive:
Line 541:                     dStats['lunGUID'] = vmDrive.GUID
Line 542:                 if sInfo is not None and eInfo is not None and (
Just to make sure we are not hiding real errors - is eInfo expected to be None in normal flow?
Line 543:                         vmDrive.name in sInfo and vmDrive.name in eInfo):
Line 544:                     # will be None if sampled during recovery
Line 545:                     dStats.update(self._calcDiskRate(vmDrive, sInfo, eInfo,
Line 546:                                                      sampleInterval))


Line 539:                     dStats['imageID'] = vmDrive.imageID
Line 540:                 elif "GUID" in vmDrive:
Line 541:                     dStats['lunGUID'] = vmDrive.GUID
Line 542:                 if sInfo is not None and eInfo is not None and (
Line 543:                         vmDrive.name in sInfo and vmDrive.name in eInfo):
The original code had unneeded parenthesis around the last two checks - this will be more clear as:

    if (sInfo is not None and vmDrive.name in sInfo and
        eInfo is not None and vmDrive.name in eInfo):

And since {} is ok with this code, we can make much nicer:

    if (sInfo and vmDrive.name in sInfo and
        eInfo and vmDrive.name in eInfo):

Since we do treat {} just like None, I would check if we can return {} instead of None which will make this condition:

    if vmDrive.name in sInfo and vmDrive.name in eInfo:
        ...

I think this is good enough as is since we must have this in the next build, but please consider the first two cleanups for this patch.
Line 544:                     # will be None if sampled during recovery
Line 545:                     dStats.update(self._calcDiskRate(vmDrive, sInfo, eInfo,
Line 546:                                                      sampleInterval))
Line 547:             except (AttributeError, TypeError, ZeroDivisionError):


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I059b69c33d45950f8377597ee8c6e7824e1ec223
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: automation at ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes


More information about the vdsm-patches mailing list