Dan Kenigsberg has uploaded a new change for review. Change subject: sampling.ImagePathStatus: drop unused code, and only it ......................................................................
sampling.ImagePathStatus: drop unused code, and only it The ImagePathStatus is never started, but one of its methods is used by HostStatsThread.get(). This patch moves the still-used bits of ImagePathStatus code into HostStatsThread. Change-Id: I530b6d83c6ab5d0cc52df797ae3e40998fb77435 Signed-off-by: Dan Kenigsberg <[email protected]> --- M lib/vdsm/config.py.in M vdsm/sampling.py 2 files changed, 20 insertions(+), 50 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/38/21038/1 diff --git a/lib/vdsm/config.py.in b/lib/vdsm/config.py.in index c0bdd53..c8ce7e6 100644 --- a/lib/vdsm/config.py.in +++ b/lib/vdsm/config.py.in @@ -194,9 +194,6 @@ ('irsd', '%(images)s/irsd', None), - ('images_check_times', '0', - 'Image repository check period (seconds).'), - ('volume_utilization_percent', '50', None), ('volume_utilization_chunk_mb', '1024', None), diff --git a/vdsm/sampling.py b/vdsm/sampling.py index 09e3dd4..04593de 100644 --- a/vdsm/sampling.py +++ b/vdsm/sampling.py @@ -36,7 +36,6 @@ from vdsm import utils from vdsm import netinfo from vdsm.constants import P_VDSM_RUN -from vdsm.config import config _THP_STATE_PATH = '/sys/kernel/mm/transparent_hugepage/enabled' if not os.path.exists(_THP_STATE_PATH): @@ -377,12 +376,11 @@ self._lineRate = (sum(self._ifrates) or 1000) * (10 ** 6) / 8 self._lastSampleTime = time.time() - self._imagesStatus = ImagePathStatus(cif) + self._cif = cif self._pid = os.getpid() self._ncpus = max(os.sysconf('SC_NPROCESSORS_ONLN'), 1) def stop(self): - self._imagesStatus.stop() self._stopEvent.set() def _updateIfidsIfrates(self): @@ -418,19 +416,9 @@ def get(self): stats = self._getInterfacesStats() stats['cpuSysVdsmd'] = stats['cpuUserVdsmd'] = 0.0 - stats['storageDomains'] = {} - if self._imagesStatus._cif.irs: - self._imagesStatus._refreshStorageDomains() + stats['storageDomains'] = self._getStorageDomainsStats() + now = time.time() - for sd, d in self._imagesStatus.storageDomains.iteritems(): - stats['storageDomains'][sd] = { - 'code': d['code'], - 'delay': d['delay'], - 'lastCheck': d['lastCheck'], - 'valid': d['valid'], - 'version': d['version'], - 'acquired': d['acquired'], - } stats['elapsedTime'] = int(now - self.startTime) if len(self._samples) < 2: return stats @@ -519,41 +507,26 @@ stats['txRate'] = min(stats['txRate'], 100.0) stats['rxRate'] = min(stats['rxRate'], 100.0) logging.debug(stats) -# stats['rxBps'] = float(rx) / interval -# stats['txBps'] = float(tx) / interval stats['rxDropped'] = rxDropped stats['txDropped'] = txDropped return stats + def _getStorageDomainsStats(self): + sds = {} + if self._cif.irs: + res = self._cif.irs.repoStats() + del res["status"] + if "args" in res: + del res["args"] -class ImagePathStatus(threading.Thread): - def __init__(self, cif, interval=None): - if interval is None: - interval = config.getint('irs', 'images_check_times') - self._interval = interval - self._cif = cif - self.storageDomains = {} - self._stopEvent = threading.Event() - threading.Thread.__init__(self, name='ImagePathStatus') - if self._interval > 0: - self.start() - - def stop(self): - self._stopEvent.set() - - def _refreshStorageDomains(self): - self.storageDomains = self._cif.irs.repoStats() - del self.storageDomains["status"] - if "args" in self.storageDomains: - del self.storageDomains["args"] - - def run(self): - try: - while not self._stopEvent.isSet(): - if self._cif.irs: - self._refreshStorageDomains() - self._stopEvent.wait(self._interval) - except: - logging.error("Error while refreshing storage domains", - exc_info=True) + for sd, d in res.iteritems(): + sds[sd] = { + 'code': d['code'], + 'delay': d['delay'], + 'lastCheck': d['lastCheck'], + 'valid': d['valid'], + 'version': d['version'], + 'acquired': d['acquired'], + } + return sds -- To view, visit http://gerrit.ovirt.org/21038 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I530b6d83c6ab5d0cc52df797ae3e40998fb77435 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Dan Kenigsberg <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
