Francesco Romani has uploaded a new change for review.
Change subject: sampling: remove HostStatsThread.get() ......................................................................
sampling: remove HostStatsThread.get()
Remove the get() operation of HostStatsThread, decouple sample storage and stats production,
Change-Id: I80d919b0adb48a40d41f387543f14be265610405 Signed-off-by: Francesco Romani fromani@redhat.com --- M tests/samplingTests.py M vdsm/API.py M vdsm/clientIF.py M vdsm/virt/sampling.py 4 files changed, 22 insertions(+), 16 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/36/42036/1
diff --git a/tests/samplingTests.py b/tests/samplingTests.py index ab85834..0b0bd2b 100644 --- a/tests/samplingTests.py +++ b/tests/samplingTests.py @@ -262,11 +262,13 @@ 'rxRate': 0.0, 'txRate': 0.0, } - self._hs = sampling.HostStatsThread(self.log) - self.assertEquals(self._hs.get(), expected) + self.assertEquals(hoststats.produce(None, None), expected)
def testSamplesWraparound(self): - NUM = sampling.HostStatsThread.AVERAGING_WINDOW + 1 + NUM = sampling.HOST_STATS_AVERAGING_WINDOW + 1 + + samples = sampling.SampleWindow( + sampling.HOST_STATS_AVERAGING_WINDOW)
class FakeEvent(object): def __init__(self, *args): @@ -299,16 +301,16 @@ pass
with MonkeyPatchScope([(sampling, 'HostSample', FakeHostSample)]): - self._hs = sampling.HostStatsThread(self.log) + self._hs = sampling.HostStatsThread(self.log, samples) self._hs._sampleInterval = 0 # we cannot monkey patch, it will interfer on threading internals self._hs._stopEvent = FakeEvent() self._hs.start() self._hs.join() - first, last, _ = self._hs._samples.stats() + first, last, _ = samples.stats() self.assertEqual(first.id, FakeHostSample.counter - - sampling.HostStatsThread.AVERAGING_WINDOW) + sampling.HOST_STATS_AVERAGING_WINDOW) self.assertEqual(last.id, FakeHostSample.counter - 1)
diff --git a/vdsm/API.py b/vdsm/API.py index 397f87e..e05a939 100644 --- a/vdsm/API.py +++ b/vdsm/API.py @@ -43,6 +43,8 @@ import storage.volume import storage.sd import storage.image +from virt import hoststats +from virt import sampling from virt import vmstatus from virt.vmdevices import graphics from virt.vmdevices import hwclass @@ -1318,7 +1320,8 @@ hooks.before_get_stats() stats = {} decStats = {'elapsedTime': self._cif.elapsed_time} - decStats.update(self._cif._hostStats.get()) + first_sample, last_sample, _ = sampling.host_samples.stats() + decStats.update(hoststats.produce(first_sample, last_sample))
if self._cif.irs: decStats['storageDomains'] = self._cif.irs.repoStats() diff --git a/vdsm/clientIF.py b/vdsm/clientIF.py index c8ef6f6..6cd5e7f 100644 --- a/vdsm/clientIF.py +++ b/vdsm/clientIF.py @@ -94,7 +94,8 @@ self.gluster = None try: self.vmContainer = {} - self._hostStats = sampling.HostStatsThread(log=log) + self._hostStats = sampling.HostStatsThread( + log, sampling.host_samples) self._hostStats.start() self._startTime = time.time() self.lastRemoteAccess = 0 diff --git a/vdsm/virt/sampling.py b/vdsm/virt/sampling.py index 401bae9..40cb3ee 100644 --- a/vdsm/virt/sampling.py +++ b/vdsm/virt/sampling.py @@ -37,7 +37,6 @@ from vdsm.config import config
from .utils import ExpiringCache -from . import hoststats
import caps
@@ -524,19 +523,24 @@ return doms
+HOST_STATS_AVERAGING_WINDOW = 5 + + +host_samples = SampleWindow(size=HOST_STATS_AVERAGING_WINDOW) + + class HostStatsThread(threading.Thread): """ A thread that periodically samples host statistics. """ - AVERAGING_WINDOW = 5 _CONNLOG = logging.getLogger('connectivity')
- def __init__(self, log): + def __init__(self, log, samples): threading.Thread.__init__(self) self.daemon = True self._log = log self._stopEvent = threading.Event() - self._samples = SampleWindow(size=self.AVERAGING_WINDOW) + self._samples = samples
self._pid = os.getpid() self._ncpus = max(os.sysconf('SC_NPROCESSORS_ONLN'), 1) @@ -569,10 +573,6 @@ except: if not self._stopEvent.isSet(): self._log.exception("Error while sampling stats") - - def get(self): - first_sample, last_sample, _ = self._samples.stats() - return hoststats.produce(first_sample, last_sample)
def _getLinkSpeed(dev):
automation@ovirt.org has posted comments on this change.
Change subject: sampling: remove HostStatsThread.get() ......................................................................
Patch Set 1:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: sampling: remove HostStatsThread.get() ......................................................................
Patch Set 2:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: sampling: remove HostStatsThread.get() ......................................................................
Patch Set 3:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: sampling: remove HostStatsThread.get() ......................................................................
Patch Set 4:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: sampling: remove HostStatsThread.get() ......................................................................
Patch Set 5:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: sampling: remove HostStatsThread.get() ......................................................................
Patch Set 6:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: sampling: remove HostStatsThread.get() ......................................................................
Patch Set 7:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: sampling: remove HostStatsThread.get() ......................................................................
Patch Set 8:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: sampling: remove HostStatsThread.get() ......................................................................
Patch Set 9:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: sampling: remove HostStatsThread.get() ......................................................................
Patch Set 10:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: sampling: remove HostStatsThread.get() ......................................................................
Patch Set 11:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: sampling: remove HostStatsThread.get() ......................................................................
Patch Set 12:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: sampling: remove HostStatsThread.get() ......................................................................
Patch Set 13:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: sampling: remove HostStatsThread.get() ......................................................................
Patch Set 14:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: sampling: remove HostStatsThread.get() ......................................................................
Patch Set 15:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
Roman Mohr has posted comments on this change.
Change subject: sampling: remove HostStatsThread.get() ......................................................................
Patch Set 15:
(1 comment)
https://gerrit.ovirt.org/#/c/42036/15/vdsm/virt/sampling.py File vdsm/virt/sampling.py:
Line 550: samples As far as I can see we only pass there something else than host_samples in when we want to fake the SampleWindow in the tests. You could make host_samples the default value.
Francesco Romani has posted comments on this change.
Change subject: sampling: remove HostStatsThread.get() ......................................................................
Patch Set 15:
(1 comment)
https://gerrit.ovirt.org/#/c/42036/15/vdsm/virt/sampling.py File vdsm/virt/sampling.py:
Line 550: samples
As far as I can see we only pass there something else than host_samples in
Fair point. Done!
automation@ovirt.org has posted comments on this change.
Change subject: sampling: remove HostStatsThread.get() ......................................................................
Patch Set 16:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
Francesco Romani has posted comments on this change.
Change subject: sampling: remove HostStatsThread.get() ......................................................................
Patch Set 16: Verified+1
verified running patched VDSM that vds stats are still collected and reported (checked using vdsClient)
automation@ovirt.org has posted comments on this change.
Change subject: sampling: remove HostStatsThread.get() ......................................................................
Patch Set 17:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
Dan Kenigsberg has posted comments on this change.
Change subject: sampling: remove HostStatsThread.get() ......................................................................
Patch Set 17: Code-Review+2
automation@ovirt.org has posted comments on this change.
Change subject: sampling: remove HostStatsThread.get() ......................................................................
Patch Set 18:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
Dan Kenigsberg has submitted this change and it was merged.
Change subject: sampling: remove HostStatsThread.get() ......................................................................
sampling: remove HostStatsThread.get()
Remove the get() operation of HostStatsThread, in order to decouple the code that stores sample and the code that produce the stats.
Change-Id: I80d919b0adb48a40d41f387543f14be265610405 Signed-off-by: Francesco Romani fromani@redhat.com Reviewed-on: https://gerrit.ovirt.org/42036 Reviewed-by: Dan Kenigsberg danken@redhat.com Continuous-Integration: Jenkins CI --- M tests/hoststatsTests.py M tests/samplingTests.py M vdsm/API.py M vdsm/clientIF.py M vdsm/virt/sampling.py 5 files changed, 37 insertions(+), 28 deletions(-)
Approvals: Jenkins CI: Passed CI tests Dan Kenigsberg: Looks good to me, approved Francesco Romani: Verified
automation@ovirt.org has posted comments on this change.
Change subject: sampling: remove HostStatsThread.get() ......................................................................
Patch Set 19:
* Update tracker: IGNORE, no Bug-Url found * Set MODIFIED::IGNORE, no Bug-Url found.
vdsm-patches@lists.fedorahosted.org