Change in vdsm[master]: betterasynccore: Prevent double close
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: betterasynccore: Prevent double close
......................................................................
betterasynccore: Prevent double close
asyncore.dispatcher is defining a closing attribute, but never use it.
This make it possible to close a dispatcher multiple times, failing with
KeyError after the first call.
Because of the asynchronous nature of the reactor, it is very hard to
ensure that all dispatchers are closed before the reactor, so we need a
more robust close method.
This patch uses the closing attribute to eliminate double close errors.
Change-Id: Ia293deb79affc2f740d825e24ce8c66449385111
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M lib/yajsonrpc/betterAsyncore.py
1 file changed, 6 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/09/65209/1
diff --git a/lib/yajsonrpc/betterAsyncore.py b/lib/yajsonrpc/betterAsyncore.py
index c32b54c..b86c919 100644
--- a/lib/yajsonrpc/betterAsyncore.py
+++ b/lib/yajsonrpc/betterAsyncore.py
@@ -69,6 +69,12 @@
def handle_write(self):
self._delegate_call("handle_write")
+ def close(self):
+ if self.closing:
+ return
+ self.closing = True
+ asyncore.dispatcher.close(self)
+
def switch_implementation(self, impl):
self.__impl = impl
--
To view, visit https://gerrit.ovirt.org/65209
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia293deb79affc2f740d825e24ce8c66449385111
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
6 years, 5 months
Change in vdsm[master]: protocoldetector: Fix random double close
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: protocoldetector: Fix random double close
......................................................................
protocoldetector: Fix random double close
Previously we stopped the reactor before closing the acceptor. This
works most of the time, but once in a while, it fails with this error:
Traceback (most recent call last):
File "vdsm/tests/protocoldetectorTests.py", line 113, in tearDown
self.acceptor.stop()
File "vdsm/lib/vdsm/protocoldetector.py", line 211, in stop
self._acceptor.close()
File "/usr/lib64/python2.7/asyncore.py", line 407, in close
self.del_channel()
File "vdsm/lib/yajsonrpc/betterAsyncore.py", line 137, in del_channel
asyncore.dispatcher.del_channel(self, map)
File "/usr/lib64/python2.7/asyncore.py", line 292, in del_channel
del map[fd]
KeyError: 63
The flow of events leading to this error is:
1. Stooping reactor, signaling the reactor thread via eventfd
2. Context switch to the reactor thread
3. Reactor find it it was closed and close all dispatchers
4. Context switch to the original thread
5. Closing acceptor, fd is not in asyncore map
This patch fixes this issue by closing the acceptor before stopping the
reactor.
Change-Id: I0cec41c4baebcc620b70e19e62febed5dc9c542d
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M lib/vdsm/protocoldetector.py
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/87/65187/1
diff --git a/lib/vdsm/protocoldetector.py b/lib/vdsm/protocoldetector.py
index 196a2ab..e505aa7 100644
--- a/lib/vdsm/protocoldetector.py
+++ b/lib/vdsm/protocoldetector.py
@@ -207,8 +207,8 @@
def stop(self):
self.log.debug("Stopping Acceptor")
- self._reactor.stop()
self._acceptor.close()
+ self._reactor.stop()
class _CannotDetectProtocol(Exception):
--
To view, visit https://gerrit.ovirt.org/65187
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0cec41c4baebcc620b70e19e62febed5dc9c542d
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
6 years, 5 months
Change in vdsm[master]: py3: fix remaining references to monitor.MonitorError as ite...
by Dan Kenigsberg
Dan Kenigsberg has uploaded a new change for review.
Change subject: py3: fix remaining references to monitor.MonitorError as iterable
......................................................................
py3: fix remaining references to monitor.MonitorError as iterable
Change-Id: Ic991c1a017f09431d4b38f58e529d0a6ec45a896
Signed-off-by: Dan Kenigsberg <danken(a)redhat.com>
---
M init/wait_for_ipv4s
M tests/network/nettestlib.py
2 files changed, 2 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/29/64929/1
diff --git a/init/wait_for_ipv4s b/init/wait_for_ipv4s
index c1e7f32..ab119de 100755
--- a/init/wait_for_ipv4s
+++ b/init/wait_for_ipv4s
@@ -51,7 +51,7 @@
if not ipless_devs:
return
except monitor.MonitorError as e:
- if e[0] == monitor.E_TIMEOUT:
+ if e.args[0] == monitor.E_TIMEOUT:
sys.stderr.write('IP addresses has not been caught within the '
'given timeout.\n')
else:
diff --git a/tests/network/nettestlib.py b/tests/network/nettestlib.py
index bf32ea3..a5fc461 100644
--- a/tests/network/nettestlib.py
+++ b/tests/network/nettestlib.py
@@ -464,7 +464,7 @@
return
except monitor.MonitorError as e:
- if e[0] == monitor.E_TIMEOUT:
+ if e.args[0] == monitor.E_TIMEOUT:
raise Exception(
'IPv6 addresses has not been caught within 20sec.\n'
'Event log: {}\n'.format(logevents))
--
To view, visit https://gerrit.ovirt.org/64929
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic991c1a017f09431d4b38f58e529d0a6ec45a896
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken(a)redhat.com>
6 years, 5 months
Change in vdsm[master]: v2v: support for block devices
by shavivi@redhat.com
Shahar Havivi has uploaded a new change for review.
Change subject: v2v: support for block devices
......................................................................
v2v: support for block devices
extended support for block devices for KVM and VMWare.
currently we do support block devices that exported as file in libvirt:
<disk type='file' device='disk'>
<source file='...'/>
...
Added support for type block:
<disk type='block' device='disk'>
<source dev='/dev/mapper/...'/>
...
Bug-Url: https://bugzilla.redhat.com/1378340
Change-Id: I5f7a85715764efded7b296e858b130a05fe10f2a
Signed-off-by: Shahar Havivi <shaharh(a)redhat.com>
---
M lib/vdsm/v2v.py
1 file changed, 6 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/72/64272/1
diff --git a/lib/vdsm/v2v.py b/lib/vdsm/v2v.py
index 4752477..ceb2b2b 100644
--- a/lib/vdsm/v2v.py
+++ b/lib/vdsm/v2v.py
@@ -1066,6 +1066,7 @@
def _add_disks(root, params):
params['disks'] = []
disks = root.findall('.//disk[@type="file"]')
+ disks = disks + root.findall('.//disk[@type="block"]')
for disk in disks:
d = {}
device = disk.get('device')
@@ -1077,6 +1078,11 @@
source = disk.find('./source/[@file]')
if source is not None:
d['alias'] = source.get('file')
+ else:
+ source = disk.find('./source/[@dev]')
+ if source is not None:
+ d['alias'] = source.get('dev')
+
driver = disk.find('./driver/[@type]')
if driver is not None:
try:
--
To view, visit https://gerrit.ovirt.org/64272
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5f7a85715764efded7b296e858b130a05fe10f2a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Shahar Havivi <shavivi(a)redhat.com>
6 years, 5 months
Change in vdsm[master]: after_vm_destroy.py: migrate to jsonrpcvdscli
by igoihman@redhat.com
Irit Goihman has uploaded a new change for review.
Change subject: after_vm_destroy.py: migrate to jsonrpcvdscli
......................................................................
after_vm_destroy.py: migrate to jsonrpcvdscli
vdscli is deprecated and replaced by jsonrpcvdscli
Change-Id: I3f3fa6479dde2c4a1298d0ae167d888d9f7e020a
Signed-off-by: Irit Goihman <igoihman(a)redhat.com>
---
M vdsm_hooks/vhostmd/after_vm_destroy.py
1 file changed, 10 insertions(+), 4 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/83/62383/1
diff --git a/vdsm_hooks/vhostmd/after_vm_destroy.py b/vdsm_hooks/vhostmd/after_vm_destroy.py
index e8887bd..7064286 100644
--- a/vdsm_hooks/vhostmd/after_vm_destroy.py
+++ b/vdsm_hooks/vhostmd/after_vm_destroy.py
@@ -1,6 +1,6 @@
#!/usr/bin/python
#
-# Copyright 2011 Red Hat, Inc.
+# Copyright 2011-2016 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -22,14 +22,20 @@
import os
import subprocess
import hooking
-from vdsm import vdscli
-s = vdscli.connect()
+from vdsm.config import config
+from vdsm import jsonrpcvdscli
-res = s.list(True)
+requestQueues = config.get("addresses", "request_queues")
+requestQueue = requestQueues.split(",")[0]
+server = jsonrpcvdscli.connect(requestQueue=requestQueue)
+
+res = server.list(True)
if res['status']['code'] == 0:
if not [v for v in res['vmList']
if v.get('vmId') != os.environ.get('vmId') and
hooking.tobool(v.get('custom', {}).get('sap_agent', False))]:
subprocess.call(['/usr/bin/sudo', '-n', '/sbin/service', 'vhostmd',
'stop'])
+
+server.close()
--
To view, visit https://gerrit.ovirt.org/62383
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3f3fa6479dde2c4a1298d0ae167d888d9f7e020a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Irit Goihman <igoihman(a)redhat.com>
6 years, 5 months
Change in vdsm[master]: py3: make network/tc_test pass
by Dan Kenigsberg
Dan Kenigsberg has uploaded a new change for review.
Change subject: py3: make network/tc_test pass
......................................................................
py3: make network/tc_test pass
Change-Id: I544446358e611a0507aad7d7df4ab6c57ad5bdf0
Signed-off-by: Dan Kenigsberg <danken(a)redhat.com>
---
M tests/Makefile.am
M tests/network/tc_test.py
2 files changed, 8 insertions(+), 9 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/98/63198/1
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 2dce548..7243e50 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -201,7 +201,6 @@
network/ovs_driver_test.py \
network/ovs_info_test.py \
network/ovs_test.py \
- network/tc_test.py \
network/unified_persistence_test.py \
numaUtilsTests.py \
outOfProcessTests.py \
diff --git a/tests/network/tc_test.py b/tests/network/tc_test.py
index 7ac30c0..12bd17e 100644
--- a/tests/network/tc_test.py
+++ b/tests/network/tc_test.py
@@ -25,14 +25,14 @@
import os
import sys
from binascii import unhexlify
-from itertools import izip_longest
from subprocess import Popen, PIPE
from nose.plugins.attrib import attr
import six
+from six.moves import zip_longest
-from hostdevTests import Connection
+from vmfakecon import Connection
from testlib import (VdsmTestCase as TestCaseBase, permutations,
expandPermutations)
from testValidation import ValidateRunningAsRoot, stresstest
@@ -170,8 +170,8 @@
with open(path) as tc_filter_show:
data = tc_filter_show.read()
- for parsed, correct in izip_longest(tc._filters(None, out=data),
- filters):
+ for parsed, correct in zip_longest(tc._filters(None, out=data),
+ filters):
self.assertEqual(parsed, correct)
def test_qdiscs(self):
@@ -220,8 +220,8 @@
'target': 5000.0, 'interval': 150000.0,
'ecn': True}},
)
- for parsed, correct in izip_longest(tc.qdiscs(None, out=data),
- qdiscs):
+ for parsed, correct in zip_longest(tc.qdiscs(None, out=data),
+ qdiscs):
self.assertEqual(parsed, correct)
def test_classes(self):
@@ -265,8 +265,8 @@
'leaf': '5000:', 'hfsc': {'ls': {'m1': 0, 'd': 0,
'm2': reported_ls_5000}}},
)
- for parsed, correct in izip_longest(tc.classes(None, out=data),
- classes):
+ for parsed, correct in zip_longest(tc.classes(None, out=data),
+ classes):
self.assertEqual(parsed, correct)
--
To view, visit https://gerrit.ovirt.org/63198
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I544446358e611a0507aad7d7df4ab6c57ad5bdf0
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken(a)redhat.com>
6 years, 6 months
Change in vdsm[master]: virt: Destroy VM after post-copy migration failure
by mzamazal@redhat.com
Milan Zamazal has uploaded a new change for review.
Change subject: virt: Destroy VM after post-copy migration failure
......................................................................
virt: Destroy VM after post-copy migration failure
As explained in the source code comment, we don't have currently a
better option than to destroy the VM remnants after a failed post-copy
migration. This may change in future, if a failed post-copy migration
recovery is available in libvirt/QEMU.
Change-Id: I1918e9afce189c8b3f617766e55afa13f1e153f1
Signed-off-by: Milan Zamazal <mzamazal(a)redhat.com>
Bug-Url: https://bugzilla.redhat.com/1354343
---
M lib/vdsm/virt/vmexitreason.py
M vdsm/virt/vm.py
2 files changed, 24 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/42/64142/7
diff --git a/lib/vdsm/virt/vmexitreason.py b/lib/vdsm/virt/vmexitreason.py
index 46c092b..494cd28 100644
--- a/lib/vdsm/virt/vmexitreason.py
+++ b/lib/vdsm/virt/vmexitreason.py
@@ -30,6 +30,7 @@
MIGRATION_FAILED = 8
LIBVIRT_DOMAIN_MISSING = 9
DESTROYED_ON_STARTUP = 10
+POSTCOPY_MIGRATION_FAILED = 11
exitReasons = {
@@ -44,4 +45,5 @@
MIGRATION_FAILED: 'VM failed to migrate',
LIBVIRT_DOMAIN_MISSING: 'Failed to find the libvirt domain',
DESTROYED_ON_STARTUP: 'VM destroyed during the startup',
+ POSTCOPY_MIGRATION_FAILED: 'Migration failed in post-copy',
}
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index ed60354..e274388 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -4163,7 +4163,28 @@
else:
hooks.after_vm_pause(domxml, self.conf)
elif detail == libvirt.VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY_FAILED:
- pass # will be handled in a followup patch
+ # This can happen on both the ends of the migration.
+ # After a failed post-copy migration, the VM remains in a
+ # paused state on both the ends of the migration. There is
+ # currently no way to recover it, since the VM is missing some
+ # memory pages on the destination and the old snapshot at the
+ # source doesn't know about the changes made to the external
+ # world (network, storage, ...) during the post-copy phase.
+ # The best what we can do in such a situation is to destroy the
+ # paused VM instances on both the ends before someone tries to
+ # resume any of them, causing confusion at best or more damages
+ # in the worse case. We must also inform Engine about the
+ # fatal state of the failed migration, so we can't destroy the
+ # VM immediately on the destination (but we can do it on the
+ # source). We report the VM as down on the destination to
+ # Engine and wait for destroy request from it.
+ self.log.warning("Migration failed in post-copy, "
+ "destroying VM: %s" % (self.id,))
+ destroy = self.lastStatus == vmstatus.MIGRATION_SOURCE
+ self.setDownStatus(ERROR,
+ vmexitreason.POSTCOPY_MIGRATION_FAILED)
+ if destroy:
+ self.destroy()
elif event == libvirt.VIR_DOMAIN_EVENT_RESUMED:
self._setGuestCpuRunning(True)
--
To view, visit https://gerrit.ovirt.org/64142
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1918e9afce189c8b3f617766e55afa13f1e153f1
Gerrit-PatchSet: 7
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Milan Zamazal <mzamazal(a)redhat.com>
Gerrit-Reviewer: Arik Hadas <ahadas(a)redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani(a)redhat.com>
Gerrit-Reviewer: gerrit-hooks <automation(a)ovirt.org>
6 years, 6 months
Change in vdsm[master]: vmstats: user proper way to detect host devices
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: vmstats: user proper way to detect host devices
......................................................................
vmstats: user proper way to detect host devices
Lacking better ways, back in time we detected host devices
checking their name (!). Now we the code is evolved and we
have proper and safer way to do the same task, so this patch
updates the vmstats code accordingly.
Change-Id: Ic71db639b980dbdf29284c432f4acda95b402c4f
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M lib/vdsm/virt/vmstats.py
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/71/65771/1
diff --git a/lib/vdsm/virt/vmstats.py b/lib/vdsm/virt/vmstats.py
index 8e271cb..9b65fbd 100644
--- a/lib/vdsm/virt/vmstats.py
+++ b/lib/vdsm/virt/vmstats.py
@@ -330,7 +330,7 @@
last_indexes = _find_bulk_stats_reverse_map(last_sample, 'net')
for nic in vm.getNicDevices():
- if nic.name.startswith('hostdev'):
+ if nic.is_hostdevice:
continue
# may happen if nic is a new hot-plugged one
--
To view, visit https://gerrit.ovirt.org/65771
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic71db639b980dbdf29284c432f4acda95b402c4f
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
6 years, 6 months
Change in vdsm[master]: Enable metrics by default
by Code Review
From Yaniv Bronhaim <ybronhei(a)redhat.com>:
Yaniv Bronhaim has uploaded a new change for review.
Change subject: Enable metrics by default
......................................................................
Enable metrics by default
Same patch as https://gerrit.ovirt.org/#/c/66229, adding the missing
requirement.
Change-Id: I12201f3e2a6b4c8f0a5ea7efbc422821f362f7d1
Signed-off-by: Yaniv Bronhaim <ybronhei(a)redhat.com>
---
M lib/vdsm/config.py.in
M vdsm.spec.in
2 files changed, 3 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/57/66257/1
diff --git a/lib/vdsm/config.py.in b/lib/vdsm/config.py.in
index 47184ab..d606da2 100644
--- a/lib/vdsm/config.py.in
+++ b/lib/vdsm/config.py.in
@@ -452,8 +452,8 @@
# Section: [metrics]
('metrics', [
- ('enabled', 'false',
- 'Enable metrics collection (default false)'),
+ ('enabled', 'true',
+ 'Enable metrics collection (default true)'),
('collector_address', 'localhost',
'Metrics collector address (default localhost)'),
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 7d5154a..eb5cd22 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -96,6 +96,7 @@
Requires: python-ioprocess >= 0.16.1-1
Requires: python-pthreading >= 0.1.3-3
Requires: python-six >= 1.9.0
+Requires: python-statsd
Requires: python-requests
Requires: rpm-python
Requires: nfs-utils
--
To view, visit https://gerrit.ovirt.org/66257
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I12201f3e2a6b4c8f0a5ea7efbc422821f362f7d1
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yaniv Bronhaim <ybronhei(a)redhat.com>
6 years, 6 months
Change in vdsm[master]: Adding StatsClient to code base to avoid using python-statsd...
by Code Review
From Yaniv Bronhaim <ybronhei(a)redhat.com>:
Yaniv Bronhaim has uploaded a new change for review.
Change subject: Adding StatsClient to code base to avoid using python-statsd package
......................................................................
Adding StatsClient to code base to avoid using python-statsd package
The code is not so complex so I copied it. We use only few parts of it.
I might remove also the rest that we don't use. Quite simple
Change-Id: I7bbc8a4c0e3afc25c205bfec58c5e77096803404
Signed-off-by: Yaniv Bronhaim <ybronhei(a)redhat.com>
---
M lib/vdsm/metrics/statsd.py
1 file changed, 52 insertions(+), 7 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/04/67004/1
diff --git a/lib/vdsm/metrics/statsd.py b/lib/vdsm/metrics/statsd.py
index f471317..24562aa 100644
--- a/lib/vdsm/metrics/statsd.py
+++ b/lib/vdsm/metrics/statsd.py
@@ -19,14 +19,11 @@
#
from __future__ import absolute_import
+from __future__ import with_statement
+import random
import six
-from vdsm import compat
-
-try:
- import statsd
-except ImportError as e:
- raise compat.Unsupported(str(e))
+import socket
_client = None
@@ -34,7 +31,7 @@
def start(address):
global _client
if _client is None:
- _client = statsd.StatsClient(host=address)
+ _client = StatsClient(host=address)
def stop():
@@ -45,3 +42,51 @@
def send(report):
for name, value in six.iteritems(report):
_client.gauge(name, value)
+
+
+class StatsClient(object):
+ def __init__(self, host='localhost', port=8125, prefix=None,
+ maxudpsize=512, ipv6=False):
+ fam = socket.AF_INET6 if ipv6 else socket.AF_INET
+ family, _, _, _, addr = socket.getaddrinfo(
+ host, port, fam, socket.SOCK_DGRAM)[0]
+ self._addr = addr
+ self._sock = socket.socket(family, socket.SOCK_DGRAM)
+ self._prefix = prefix
+ self._maxudpsize = maxudpsize
+
+ def _send(self, data):
+ try:
+ self._sock.sendto(data.encode('ascii'), self._addr)
+ except (socket.error, RuntimeError):
+ pass
+
+ def gauge(self, stat, value, rate=1, delta=False):
+ if value < 0 and not delta:
+ if rate < 1:
+ if random.random() > rate:
+ return
+ with self.pipeline() as pipe:
+ pipe._send_stat(stat, '0|g', 1)
+ pipe._send_stat(stat, '%s|g' % value, 1)
+ else:
+ prefix = '+' if delta and value >= 0 else ''
+ self._send_stat(stat, '%s%s|g' % (prefix, value), rate)
+
+ def _send_stat(self, stat, value, rate):
+ self._after(self._prepare(stat, value, rate))
+
+ def _prepare(self, stat, value, rate):
+ if rate < 1:
+ if random.random() > rate:
+ return
+ value = '%s|@%s' % (value, rate)
+
+ if self._prefix:
+ stat = '%s.%s' % (self._prefix, stat)
+
+ return '%s:%s' % (stat, value)
+
+ def _after(self, data):
+ if data:
+ self._send(data)
--
To view, visit https://gerrit.ovirt.org/67004
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7bbc8a4c0e3afc25c205bfec58c5e77096803404
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yaniv Bronhaim <ybronhei(a)redhat.com>
6 years, 6 months