Change in vdsm[master]: introduce connectivity log
by Dan Kenigsberg
Dan Kenigsberg has uploaded a new change for review.
Change subject: introduce connectivity log
......................................................................
introduce connectivity log
Users have been requesting to have access to a simple log file that
tracks host connectivity. This patch adds /var/log/vdsm/connectivity.log
for that purpose. It adds a line for any change of connectivity of
tracked interfaces.
Note that the connectivity change is not implemented with `ip monitor`,
since the latter seems to ignore link speed changes, which are required
to be logged.
Bug-Url: https://bugzilla.redhat.com/1111234
Change-Id: I86dc41223babe43194add7ce778c6567b2bc5823
Signed-off-by: Dan Kenigsberg <danken(a)redhat.com>
---
M tests/samplingTests.py
M vdsm/logger.conf.in
M vdsm/virt/sampling.py
3 files changed, 64 insertions(+), 8 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/72/29472/1
diff --git a/tests/samplingTests.py b/tests/samplingTests.py
index 9890dd3..f2fc59b 100644
--- a/tests/samplingTests.py
+++ b/tests/samplingTests.py
@@ -22,6 +22,7 @@
import tempfile
import shutil
+from vdsm import ipwrapper
import virt.sampling as sampling
from testrunner import VdsmTestCase as TestCaseBase
@@ -101,3 +102,11 @@
with MonkeyPatchScope([(sampling, '_PROC_STAT_PATH',
self._extra_path)]):
self.assertEquals(sampling.getBootTime(), 1395249141)
+
+class InterfaceSampleTests(TestCaseBase):
+ def testDiff(self):
+ lo = ipwrapper.getLink('lo')
+ s0 = sampling.InterfaceSample(lo)
+ s1 = sampling.InterfaceSample(lo)
+ s1.operstate = 'x'
+ self.assertEquals('operstate:x', s1.connlog_diff(s0))
diff --git a/vdsm/logger.conf.in b/vdsm/logger.conf.in
index 5b0cf63..87159e4 100644
--- a/vdsm/logger.conf.in
+++ b/vdsm/logger.conf.in
@@ -1,8 +1,8 @@
[loggers]
-keys=root,vds,Storage,ovirt_hosted_engine_ha
+keys=root,vds,Storage,ovirt_hosted_engine_ha,connectivity
[handlers]
-keys=console,syslog,logfile
+keys=console,syslog,logfile,connlogfile
[formatters]
keys=long,simple,none,sysform
@@ -30,6 +30,12 @@
qualname=ovirt_hosted_engine_ha
propagate=1
+[logger_connectivity]
+level=DEBUG
+handlers=connlogfile
+qualname=connectivity
+propagate=0
+
[handler_syslog]
level=WARNING
class=handlers.SysLogHandler
@@ -43,13 +49,20 @@
level=DEBUG
formatter=long
+[handler_connlogfile]
+class=logging.handlers.WatchedFileHandler
+args=('@VDSMLOGDIR(a)/connectivity.log',)
+filters=storage.misc.TracebackRepeatFilter
+level=DEBUG
+formatter=simple
+
[handler_console]
class: StreamHandler
args: []
formatter: none
[formatter_simple]
-format: %(name)s:%(levelname)s: %(message)s
+format: %(asctime)s:%(levelname)s:%(message)s
[formatter_none]
format: %(message)s
@@ -60,8 +73,3 @@
[formatter_sysform]
format= vdsm %(name)s %(levelname)s %(message)s
datefmt=
-
-
-
-
-
diff --git a/vdsm/virt/sampling.py b/vdsm/virt/sampling.py
index f87a15f..591ba7f 100644
--- a/vdsm/virt/sampling.py
+++ b/vdsm/virt/sampling.py
@@ -123,6 +123,23 @@
self.operstate = self.readIfaceOperstate(ifid)
self.speed = self._getLinkSpeed(link)
+ _LOGGED_ATTRS = ('operstate', 'speed')
+
+ def _log_attrs(self, attrs):
+ return ' '.join(
+ '%s:%s' % (attr, getattr(self, attr)) for attr in attrs )
+
+ def to_connlog(self):
+ return self._log_attrs(self._LOGGED_ATTRS)
+
+ def connlog_diff(self, other):
+ """Return a textual description of the interesting stuff new to self
+ and missing in 'other'."""
+
+ return self._log_attrs(
+ attr for attr in self._LOGGED_ATTRS
+ if getattr(self, attr) != getattr(other, attr))
+
class TotalCpuSample:
"""
@@ -273,6 +290,20 @@
self.thpState = 'never'
self.cpuCores = CpuCoreSample()
self.numaNodeMem = NumaNodeMemorySample()
+
+ def to_connlog(self):
+ return ', '.join(
+ ('%s:(%s)' % (ifid, ifacesample.to_connlog()))
+ for (ifid, ifacesample) in self.interfaces.iteritems())
+
+ def connlog_diff(self, other):
+ text = ''
+ for ifid, sample in self.interfaces.iteritems():
+ if ifid in other.interfaces:
+ text += sample.connlog_diff(other.interfaces[ifid])
+ else:
+ text += 'new (%s) ' % sample.to_connlog()
+ return text
class AdvancedStatsFunction(object):
@@ -443,6 +474,7 @@
"""
AVERAGING_WINDOW = 5
SAMPLE_INTERVAL_SEC = 2
+ _CONNLOG = logging.getLogger('connectivity')
def __init__(self, log):
self.startTime = time.time()
@@ -473,6 +505,13 @@
try:
sample = self.sample()
self._samples.append(sample)
+ if len(self._samples) == 1:
+ self._CONNLOG.debug('%s', sample.to_connlog())
+ else:
+ diff = sample.connlog_diff(self._samples[-2])
+ if diff:
+ self._CONNLOG.debug('%s', diff)
+
self._lastSampleTime = sample.timestamp
if len(self._samples) > self.AVERAGING_WINDOW:
self._samples.pop(0)
--
To view, visit http://gerrit.ovirt.org/29472
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I86dc41223babe43194add7ce778c6567b2bc5823
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken(a)redhat.com>
9 years, 9 months
Change in vdsm[master]: HostStats: stop storing list of host ifids and speeds
by Dan Kenigsberg
Dan Kenigsberg has uploaded a new change for review.
Change subject: HostStats: stop storing list of host ifids and speeds
......................................................................
HostStats: stop storing list of host ifids and speeds
Current code keeps an almost-up-to-date list of host interface names as
a data member of the HostStatsThread. This information is redundant,
since host ifids are already available in HostSample.interfaces.
With the list of ifids, this patch removes a list of their respective
speed. Each speed is stored, instead with its respective
InterfaceSample.
Change-Id: Iad0605c910564a8a7072484301c51b4b8a325751
Signed-off-by: Dan Kenigsberg <danken(a)redhat.com>
---
M vdsm/virt/sampling.py
1 file changed, 29 insertions(+), 29 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/70/29470/1
diff --git a/vdsm/virt/sampling.py b/vdsm/virt/sampling.py
index 4ef9890..841f2f2 100644
--- a/vdsm/virt/sampling.py
+++ b/vdsm/virt/sampling.py
@@ -100,7 +100,20 @@
return '0'
return 'up' if flags & ethtool.IFF_RUNNING else 'down'
- def __init__(self, ifid):
+ @staticmethod
+ def _getLinkSpeed(dev):
+ if dev.isNIC():
+ speed = netinfo.nicSpeed(dev.name)
+ elif dev.isBOND():
+ speed = netinfo.bondSpeed(dev.name)
+ elif dev.isVLAN():
+ speed = netinfo.vlanSpeed(dev.name)
+ else:
+ speed = 0
+ return speed
+
+ def __init__(self, link):
+ ifid = link.name
self.rx = self.readIfaceStat(ifid, 'rx_bytes')
self.tx = self.readIfaceStat(ifid, 'tx_bytes')
self.rxDropped = self.readIfaceStat(ifid, 'rx_dropped')
@@ -108,6 +121,7 @@
self.rxErrors = self.readIfaceStat(ifid, 'rx_errors')
self.txErrors = self.readIfaceStat(ifid, 'tx_errors')
self.operstate = self.readIfaceOperstate(ifid)
+ self.speed = self._getLinkSpeed(link)
class TotalCpuSample:
@@ -192,11 +206,11 @@
"""
A sample of the statistics for a process.
"""
- def __init__(self, pid, ifids):
+ def __init__(self, pid, links):
TimedSample.__init__(self)
self.interfaces = {}
- for ifid in ifids:
- self.interfaces[ifid] = InterfaceSample(ifid)
+ for link in links:
+ self.interfaces[link.name] = InterfaceSample(link)
self.pidcpu = PidCpuSample(pid)
@@ -241,16 +255,17 @@
d[p] = {'free': str(free)}
return d
- def __init__(self, pid, ifids):
+ def __init__(self, pid):
"""
Initialize a HostSample.
:param pid: The PID of this vdsm host.
:type pid: int
- :param ifids: The IDs of the interfaces you want to sample.
- :type: list
"""
- BaseSample.__init__(self, pid, ifids)
+ TimedSample.__init__(self)
+ self.interfaces = dict(
+ (link.name, InterfaceSample(link)) for link in getLinks())
+ self.pidcpu = PidCpuSample(pid)
self.totcpu = TotalCpuSample()
meminfo = utils.readMemInfo()
freeOrCached = (meminfo['MemFree'] +
@@ -449,7 +464,6 @@
self._log = log
self._stopEvent = threading.Event()
self._samples = []
- self._updateIfidsIfrates()
self._lastSampleTime = time.time()
self._pid = os.getpid()
@@ -458,24 +472,8 @@
def stop(self):
self._stopEvent.set()
- def _updateIfidsIfrates(self):
- devices = getLinks()
- self._ifids = [dev.name for dev in devices]
- self._ifrates = []
- for dev in devices:
- if dev.isNIC():
- speed = netinfo.nicSpeed(dev.name)
- elif dev.isBOND():
- speed = netinfo.bondSpeed(dev.name)
- elif dev.isVLAN():
- speed = netinfo.vlanSpeed(dev.name)
- else:
- speed = 0
- self._ifrates.append(speed)
-
def sample(self):
- self._updateIfidsIfrates()
- hs = HostSample(self._pid, self._ifids)
+ hs = HostSample(self._pid, getLinks())
return hs
def run(self):
@@ -593,12 +591,13 @@
rx = tx = rxDropped = txDropped = 0
stats['network'] = {}
- for ifid, ifrate in zip(self._ifids, self._ifrates):
+ total_rate = 0
+ for ifid in hs1.interfaces.keys():
# it skips hot-plugged devices if we haven't enough information
# to count stats from it
if ifid not in hs0.interfaces:
continue
- ifrate = ifrate or 1000
+ ifrate = hs1.interfaces[ifid].speed or 1000
Mbps2Bps = (10 ** 6) / 8
thisRx = (hs1.interfaces[ifid].rx - hs0.interfaces[ifid].rx) % \
(2 ** 32)
@@ -629,8 +628,9 @@
tx += thisTx
rxDropped += hs1.interfaces[ifid].rxDropped
txDropped += hs1.interfaces[ifid].txDropped
+ total_rate += ifrate
- total_bytes_per_sec = (sum(self._ifrates) or 1000) * (10 ** 6) / 8
+ total_bytes_per_sec = (total_rate or 1000) * (10 ** 6) / 8
stats['rxRate'] = 100.0 * rx / interval / total_bytes_per_sec
stats['txRate'] = 100.0 * tx / interval / total_bytes_per_sec
if stats['txRate'] > 100 or stats['rxRate'] > 100:
--
To view, visit http://gerrit.ovirt.org/29470
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iad0605c910564a8a7072484301c51b4b8a325751
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken(a)redhat.com>
9 years, 9 months
Change in vdsm[master]: eliminate sampling.BaseSample
by Dan Kenigsberg
Dan Kenigsberg has uploaded a new change for review.
Change subject: eliminate sampling.BaseSample
......................................................................
eliminate sampling.BaseSample
For quite some time, BaseSample is not a common base class of anything.
It serves no meaningful abstraction, so this patch inlines into its only
user.
Change-Id: Ia1668e89ac21229cea1d5aac7ea155882f4295a0
Signed-off-by: Dan Kenigsberg <danken(a)redhat.com>
---
M vdsm/virt/sampling.py
1 file changed, 2 insertions(+), 14 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/71/29471/1
diff --git a/vdsm/virt/sampling.py b/vdsm/virt/sampling.py
index 841f2f2..f87a15f 100644
--- a/vdsm/virt/sampling.py
+++ b/vdsm/virt/sampling.py
@@ -202,18 +202,6 @@
self.timestamp = time.time()
-class BaseSample(TimedSample):
- """
- A sample of the statistics for a process.
- """
- def __init__(self, pid, links):
- TimedSample.__init__(self)
- self.interfaces = {}
- for link in links:
- self.interfaces[link.name] = InterfaceSample(link)
- self.pidcpu = PidCpuSample(pid)
-
-
_PROC_STAT_PATH = '/proc/stat'
@@ -235,7 +223,7 @@
raise ValueError('Boot time not present')
-class HostSample(BaseSample):
+class HostSample(TimedSample):
"""
A sample of host-related statistics.
@@ -473,7 +461,7 @@
self._stopEvent.set()
def sample(self):
- hs = HostSample(self._pid, getLinks())
+ hs = HostSample(self._pid)
return hs
def run(self):
--
To view, visit http://gerrit.ovirt.org/29471
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia1668e89ac21229cea1d5aac7ea155882f4295a0
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken(a)redhat.com>
9 years, 9 months
Change in vdsm[master]: HostStats: recalculate total line rate every time
by Dan Kenigsberg
Dan Kenigsberg has uploaded a new change for review.
Change subject: HostStats: recalculate total line rate every time
......................................................................
HostStats: recalculate total line rate every time
This should have been done when we started supporting host plugging in
commit b7b29e6.
Change-Id: Iad7f7eb1922967e2e8174b2b2a25f06fbf4c7d50
Signed-off-by: Dan Kenigsberg <danken(a)redhat.com>
---
M vdsm/virt/sampling.py
1 file changed, 4 insertions(+), 4 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/69/29469/1
diff --git a/vdsm/virt/sampling.py b/vdsm/virt/sampling.py
index 3b91cee..4ef9890 100644
--- a/vdsm/virt/sampling.py
+++ b/vdsm/virt/sampling.py
@@ -450,8 +450,6 @@
self._stopEvent = threading.Event()
self._samples = []
self._updateIfidsIfrates()
- # in bytes-per-second
- self._lineRate = (sum(self._ifrates) or 1000) * (10 ** 6) / 8
self._lastSampleTime = time.time()
self._pid = os.getpid()
@@ -631,8 +629,10 @@
tx += thisTx
rxDropped += hs1.interfaces[ifid].rxDropped
txDropped += hs1.interfaces[ifid].txDropped
- stats['rxRate'] = 100.0 * rx / interval / self._lineRate
- stats['txRate'] = 100.0 * tx / interval / self._lineRate
+
+ total_bytes_per_sec = (sum(self._ifrates) or 1000) * (10 ** 6) / 8
+ stats['rxRate'] = 100.0 * rx / interval / total_bytes_per_sec
+ stats['txRate'] = 100.0 * tx / interval / total_bytes_per_sec
if stats['txRate'] > 100 or stats['rxRate'] > 100:
stats['txRate'] = min(stats['txRate'], 100.0)
stats['rxRate'] = min(stats['rxRate'], 100.0)
--
To view, visit http://gerrit.ovirt.org/29469
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iad7f7eb1922967e2e8174b2b2a25f06fbf4c7d50
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken(a)redhat.com>
9 years, 9 months
Change in vdsm[master]: virt: move XML processing in a module
by asegurap@redhat.com
Antoni Segura Puimedon has posted comments on this change.
Change subject: virt: move XML processing in a module
......................................................................
Patch Set 2: Code-Review-1
(2 comments)
The module name could be jut "xml" since inside it would have Domain (which is the domxml) and Element.
http://gerrit.ovirt.org/#/c/26855/2/vdsm/virt/xmldom.py
File vdsm/virt/xmldom.py:
Line 36: def is_node(xmlNode):
Line 37: return xmlNode.nodeType == Node.ELEMENT_NODE
Line 38:
Line 39:
Line 40: class XMLElement(object):
the module is xmldom, no need for prefixes.
class Element(object):
Line 41:
Line 42: def __init__(self, tagName, text=None, **attrs):
Line 43: self._elem = xml.dom.minidom.Document().createElement(tagName)
Line 44: self.setAttrs(**attrs)
Line 64: self._elem.appendChild(child)
Line 65: return child
Line 66:
Line 67:
Line 68: class _DomXML:
> this now needs to be 'public' (to drop the leading underscore)
class Domain(object):
Line 69: def __init__(self, conf, log, arch):
Line 70: """
Line 71: Create the skeleton of a libvirt domain xml
Line 72:
--
To view, visit http://gerrit.ovirt.org/26855
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I77dd048067b8abcb77f4b9bf55fbfd0535672996
Gerrit-PatchSet: 2
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
Gerrit-Reviewer: Antoni Segura Puimedon <asegurap(a)redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken(a)redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani(a)redhat.com>
Gerrit-Reviewer: Martin Polednik <mpoledni(a)redhat.com>
Gerrit-Reviewer: Michal Skrivanek <mskrivan(a)redhat.com>
Gerrit-Reviewer: Vinzenz Feenstra <vfeenstr(a)redhat.com>
Gerrit-Reviewer: automation(a)ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
9 years, 9 months
Change in vdsm[master]: domainMonitor: Fix unsafe iteration of domain monitor status
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: domainMonitor: Fix unsafe iteration of domain monitor status
......................................................................
domainMonitor: Fix unsafe iteration of domain monitor status
When we generate repoStat response, we used to iterate over the
monitored domains, getting the status for each monitor. This naïve
approach does not consider that a monitor may be removed from the domain
monitor dict during the iteration.
Since the only usage now is getting the status for all domains, I
changed getStatus to return an iterator returning all domains status in
a safe manner.
Change-Id: I083c4b1925ee529c0993a291cad6076539d4ea66
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M vdsm/storage/domainMonitor.py
M vdsm/storage/hsm.py
2 files changed, 4 insertions(+), 5 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/09/29009/1
diff --git a/vdsm/storage/domainMonitor.py b/vdsm/storage/domainMonitor.py
index 8a50b4f..c8207d9 100644
--- a/vdsm/storage/domainMonitor.py
+++ b/vdsm/storage/domainMonitor.py
@@ -118,8 +118,9 @@
del self._domains[sdUUID]
- def getStatus(self, sdUUID):
- return self._domains[sdUUID].getStatus()
+ def getMonitoredDomainsStatus(self):
+ for sdUUID, monitor in self._domains.items():
+ yield sdUUID, monitor.getStatus()
def close(self):
self.log.info("Stopping domain monitors")
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index cc2d8a0..f0c3afb 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -3538,9 +3538,7 @@
repoStats = {}
statsGenTime = time.time()
- for sdUUID in domainMonitor.monitoredDomains:
- domStatus = domainMonitor.getStatus(sdUUID)
-
+ for sdUUID, domStatus in domainMonitor.getMonitoredDomainsStatus():
if domStatus.error is None:
code = 0
elif isinstance(domStatus.error, se.StorageException):
--
To view, visit http://gerrit.ovirt.org/29009
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I083c4b1925ee529c0993a291cad6076539d4ea66
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
9 years, 9 months
Change in vdsm[master]: core: GET requests - use Range header
by laravot@redhat.com
Liron Ar has uploaded a new change for review.
Change subject: core: GET requests - use Range header
......................................................................
core: GET requests - use Range header
This patch replaces the use of the custom Size header with use of http
Range header.
(http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35)
Currently the Range header is mandatory to issue a get request for an
image and support ranges between zero and specified last byte position.
Change-Id: I8164867347b1cf800efd2a78cc98dbc10c02ee0d
Signed-off-by: Liron Aravot <laravot(a)redhat.com>
---
M vdsm/BindingXMLRPC.py
1 file changed, 40 insertions(+), 7 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/65/28465/1
diff --git a/vdsm/BindingXMLRPC.py b/vdsm/BindingXMLRPC.py
index 08a818d..475b078 100644
--- a/vdsm/BindingXMLRPC.py
+++ b/vdsm/BindingXMLRPC.py
@@ -26,6 +26,7 @@
import logging
import libvirt
import threading
+import re
import sys
from vdsm import utils
@@ -119,9 +120,10 @@
HEADER_IMAGE = 'Image-Id'
HEADER_VOLUME = 'Volume-Id'
HEADER_TASK_ID = 'Task-Id'
- HEADER_SIZE = 'Size'
+ HEADER_RANGE = 'Range'
HEADER_CONTENT_LENGTH = 'content-length'
HEADER_CONTENT_TYPE = 'content-type'
+ HEADER_CONTENT_RANGE = 'content-range'
class RequestException():
def __init__(self, httpStatusCode, errorMessage):
@@ -135,8 +137,7 @@
def do_GET(self):
try:
- length = self._getIntHeader(self.HEADER_SIZE,
- httplib.BAD_REQUEST)
+ length = self._getLength()
img = self._createImage()
startEvent = threading.Event()
methodArgs = {'fileObj': self.wfile,
@@ -153,10 +154,12 @@
startEvent, volUUID)
if response['status']['code'] == 0:
- self.send_response(httplib.OK)
+ self.send_response(httplib.PARTIAL_CONTENT)
self.send_header(self.HEADER_CONTENT_TYPE,
'application/octet-stream')
self.send_header(self.HEADER_CONTENT_LENGTH, length)
+ self.send_header(self.HEADER_CONTENT_RANGE,
+ "bytes=0-%d" % length)
self.send_header(self.HEADER_TASK_ID, response['uuid'])
self.end_headers()
startEvent.set()
@@ -238,21 +241,51 @@
event.wait()
def _getIntHeader(self, headerName, missingError):
+ value = self._getRequiredHeader(headerName, missingError)
+
+ return self._getInt(value)
+
+ def _getRequiredHeader(self, headerName, missingError):
value = self.headers.getheader(
headerName)
if not value:
raise self.RequestException(
missingError,
"missing header %s" % headerName)
+ return value
+ def _getInt(self, value):
try:
- value = int(value)
+ return int(value)
except ValueError:
raise self.RequestException(
httplib.BAD_REQUEST,
- "invalid header value %r" % value)
+ "not int value %r" % value)
- return value
+ def _getLength(self):
+ value = self._getRequiredHeader(self.HEADER_RANGE,
+ httplib.BAD_REQUEST)
+
+ m = re.match('^bytes=(\d*)-(\d+)$', value)
+ if m is None:
+ raise self.RequestException(
+ httplib.BAD_REQUEST,
+ "range in an unsupported format")
+
+ min = m.group(1)
+ if min != '0':
+ raise self.RequestException(
+ httplib.BAD_REQUEST,
+ "range first byte position other than 0 isn't "
+ "supported")
+
+ max = m.group(2)
+ if max == '':
+ raise self.RequestException(
+ httplib.BAD_REQUEST,
+ "range last byte position must be specified")
+
+ return self._getInt(max)
def send_error(self, error, message, exc_info=False):
try:
--
To view, visit http://gerrit.ovirt.org/28465
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8164867347b1cf800efd2a78cc98dbc10c02ee0d
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Liron Ar <laravot(a)redhat.com>
9 years, 9 months
Change in vdsm[master]: domainMonitor: Fix unsafe iteration
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: domainMonitor: Fix unsafe iteration
......................................................................
domainMonitor: Fix unsafe iteration
Using dict.iteritems() is safe only if nobody else can modify the
dictionary while iterating. However in DomainMonitor, others threads can
add or remove items during the iteration, so we must use dict.items(),
which copies the keys and values atomically.
dict.iteritems() is useful when we have huge dict and we don't want to
create a huge list of items, but in case of the domain monitor, where we
have less then 100 monitors, there is not need for fancy iteration.
While modifying this line, I also improve the names to make the code
more clear, this can be separated to another patch but I don't think it
is needed in this case.
Change-Id: I5313d25c7148e4a0362d19fe31d2e78f94c26e39
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M vdsm/storage/domainMonitor.py
1 file changed, 2 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/07/29007/1
diff --git a/vdsm/storage/domainMonitor.py b/vdsm/storage/domainMonitor.py
index 8a50b4f..76afafa 100644
--- a/vdsm/storage/domainMonitor.py
+++ b/vdsm/storage/domainMonitor.py
@@ -87,7 +87,8 @@
@property
def poolMonitoredDomains(self):
- return [k for k, v in self._domains.iteritems() if v.poolDomain]
+ return [sdUUID for sdUUID, monitor in self._domains.items()
+ if monitor.poolDomain]
def startMonitoring(self, sdUUID, hostId, poolDomain=True):
domainThread = self._domains.get(sdUUID)
--
To view, visit http://gerrit.ovirt.org/29007
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5313d25c7148e4a0362d19fe31d2e78f94c26e39
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
9 years, 9 months
Change in vdsm[master]: vdsm: verifyingTransport testing
by Nir Soffer
Nir Soffer has posted comments on this change.
Change subject: vdsm: verifyingTransport testing
......................................................................
Patch Set 11: Code-Review+1
Nice!
--
To view, visit http://gerrit.ovirt.org/28858
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I1a706d4d90fdf446b06530288d947d96934e45f2
Gerrit-PatchSet: 11
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Piotr Kliczewski <piotr.kliczewski(a)gmail.com>
Gerrit-Reviewer: Dan Kenigsberg <danken(a)redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani(a)redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer(a)redhat.com>
Gerrit-Reviewer: Piotr Kliczewski <piotr.kliczewski(a)gmail.com>
Gerrit-Reviewer: Saggi Mizrahi <smizrahi(a)redhat.com>
Gerrit-Reviewer: Yaniv Bronhaim <ybronhei(a)redhat.com>
Gerrit-Reviewer: automation(a)ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: No
9 years, 9 months