Dan Kenigsberg has posted comments on this change.

Change subject: core: Add boot time to the getVdsStats API
......................................................................


Patch Set 11: Code-Review-1

(6 comments)

http://gerrit.ovirt.org/#/c/25877/11//COMMIT_MSG
Commit Message:

Line 5: CommitDate: 2014-04-02 16:18:47 +0300
Line 6: 
Line 7: core: Add boot time to the getVdsStats API
Line 8: 
Line 9: Read boot time from /proc/stat and report in host stats
> Why add a constant string (boot time never changes) in a response about sta
"Capabilities" was my initial inclination, too, but I do not care much either. 
Boot time is not a real "capability" of the host, so keeping it in stats has 
its own merit. Whatever the infra team decides is good for me.
Line 10: 
Line 11: Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1070348
Line 12: Change-Id: I319e619cdaecac2f86d0154e3adbb3beda9c57d6


http://gerrit.ovirt.org/#/c/25877/11/tests/samplingTests.py
File tests/samplingTests.py:

Line 53:             with open(path, 'w') as f:
Line 54:                 f.write(content)
Line 55:             # monkeypatch has no idea where our new file is but it 
will clean
Line 56:             # up the value for us
Line 57:             sampling.PROC_STAT_PATH = path
> Missed it, but would it be cleaner to monkey patch what you need? here you 
Right: it would be much clearer to generate the /proc/stats-replacement in 
setUp(), or even to ship it a-la cpu_info.out.
Line 58:             return sampling.getBootTime()
Line 59: 
Line 60:     def testBootTimeOk(self):
Line 61:         self.assertEquals(self.getFakeBootTime(self.fixture_good),


http://gerrit.ovirt.org/#/c/25877/11/vdsm/sampling.py
File vdsm/sampling.py:

Line 146:             self.interfaces[ifid] = InterfaceSample(ifid)
Line 147:         self.pidcpu = PidCpuSample(pid)
Line 148: 
Line 149: 
Line 150: PROC_STAT_PATH = '/proc/stat'
if you keep this constant, declare in _PRIVATE
Line 151: 
Line 152: 
Line 153: def getBootTime():
Line 154:     """


Line 149: 
Line 150: PROC_STAT_PATH = '/proc/stat'
Line 151: 
Line 152: 
Line 153: def getBootTime():
I find it simpler to pass proc_stat_path as an optional arg to this function, 
to be settable by the test.

see caps.CpuInfo.__init__
Line 154:     """
Line 155:     Returns the boot time of the machine in seconds since epoch.
Line 156: 
Line 157:     Raises IOError if file access fails, or ValueError if boot time 
not


Line 444:         except:
Line 445:             if not self._stopEvent.isSet():
Line 446:                 self._log.error("Error while sampling stats", 
exc_info=True)
Line 447: 
Line 448:     @property
@propery is useful when you'd like to hide the fact that this is implemented as 
a function, or when there are many users. Neither is the case here.
Line 449:     @utils.memoized
Line 450:     def _boot_time(self):
Line 451:         # Try to get boot time only once, if N/A just log the error 
and never
Line 452:         # include it in the response.


Line 452:         # include it in the response.
Line 453:         try:
Line 454:             return getBootTime()
Line 455:         except (IOError, ValueError) as e:
Line 456:             self._log.error('Failed to get boot time: %s', e)
use exc_info=True instead of e.
Line 457:             return None
Line 458: 
Line 459:     def get(self):
Line 460:         stats = self._getInterfacesStats()


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

Gerrit-MessageType: comment
Gerrit-Change-Id: I319e619cdaecac2f86d0154e3adbb3beda9c57d6
Gerrit-PatchSet: 11
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dima Kuznetsov <[email protected]>
Gerrit-Reviewer: Adam Litke <[email protected]>
Gerrit-Reviewer: Antoni Segura Puimedon <[email protected]>
Gerrit-Reviewer: Dan Kenigsberg <[email protected]>
Gerrit-Reviewer: Dima Kuznetsov <[email protected]>
Gerrit-Reviewer: Douglas Schilling Landgraf <[email protected]>
Gerrit-Reviewer: Nir Soffer <[email protected]>
Gerrit-Reviewer: Saggi Mizrahi <[email protected]>
Gerrit-Reviewer: Tal Nisan <[email protected]>
Gerrit-Reviewer: Yaniv Bronhaim <[email protected]>
Gerrit-Reviewer: [email protected]
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to