Change in vdsm[master]: jobs: Add when_finished callback and wire up Job.abort
by alitke@redhat.com
Adam Litke has uploaded a new change for review.
Change subject: jobs: Add when_finished callback and wire up Job.abort
......................................................................
jobs: Add when_finished callback and wire up Job.abort
Add a callback mechanism that will be triggered when a job is done, failed, or
aborted. This will be used to auto-clear finished SDM jobs from the HostJobs
manager. Since jobs.Job only implements the abort job lifecycle elements, this
patch adds support to jobs.Job for calling the callback after aborting.
Future patches will enable the callback for the SDM Job run lifecycle.
Change-Id: I73d4c167a4cf1f1da4c1e2629b7afa9c01d338fd
Signed-off-by: Adam Litke <alitke(a)redhat.com>
---
M lib/vdsm/jobs.py
M tests/jobsTests.py
2 files changed, 16 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/54/61254/1
diff --git a/lib/vdsm/jobs.py b/lib/vdsm/jobs.py
index 232981c..a4d3948 100644
--- a/lib/vdsm/jobs.py
+++ b/lib/vdsm/jobs.py
@@ -19,6 +19,7 @@
from __future__ import absolute_import
+import functools
import logging
import threading
@@ -70,6 +71,7 @@
self._status = STATUS.PENDING
self._description = description
self._error = None
+ self._finished_cb = lambda: None
@property
def id(self):
@@ -117,6 +119,10 @@
self._status = STATUS.ABORTED
logging.info('Job %r aborting...', self._id)
self._abort()
+ self._finished_cb()
+
+ def when_finished(self, fn, *args, **kwargs):
+ self._finished_cb = functools.partial(fn, *args, **kwargs)
def _abort(self):
"""
diff --git a/tests/jobsTests.py b/tests/jobsTests.py
index cb1cb89..0b2b7a1 100644
--- a/tests/jobsTests.py
+++ b/tests/jobsTests.py
@@ -158,6 +158,16 @@
self.assertEqual(response.error(jobs.AbortNotSupported.name),
jobs.abort(job.id))
+ def test_abort_finished_callback(self):
+ def cb():
+ called[0] = True
+
+ called = [False]
+ job = TestingJob()
+ job.when_finished(cb)
+ job.abort()
+ self.assertTrue(called[0])
+
@permutations([
[jobs.STATUS.PENDING, True],
[jobs.STATUS.RUNNING, True],
--
To view, visit https://gerrit.ovirt.org/61254
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I73d4c167a4cf1f1da4c1e2629b7afa9c01d338fd
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <alitke(a)redhat.com>
7 years, 7 months
Change in vdsm[master]: sdm: Autoclear sdm jobs when finished
by alitke@redhat.com
Adam Litke has uploaded a new change for review.
Change subject: sdm: Autoclear sdm jobs when finished
......................................................................
sdm: Autoclear sdm jobs when finished
The engine uses the Host.getJobs API to query the status of SDM jobs it has
run. In the common case engine polls for status and running, done, and failed
statuses as appropriate. Part of the contract between vdsm and engine states
that Host Jobs are nor persisted and can disappear at any time. Currently this
happens only at vdsm restart. When a job is missing, engine must resort to
entity polling (eg. Volume.getInfo) to determine the result of the missing job.
Our goal is to keep jobs around long enough so that engine can resolve the
status of flows efficiently but without crowding the Host.getJobs result set
with too many irrelevant jobs. This patch introduces a new configuration
setting that will delete a completed job (done, failed, aborted) after a
certain number of seconds have elapsed.
We prefer vdsm to clear jobs as opposed to engine clearing them (as is done
with the older tasks) because jobs can disappear at any time and engine must
always be prepared to handle that case.
Change-Id: I666b65d3a73380d786ac1695e4de5c3c7923effd
Signed-off-by: Adam Litke <alitke(a)redhat.com>
---
M lib/vdsm/config.py.in
M tests/sdmtestlib.py
M tests/storage_hsm_test.py
M vdsm/storage/hsm.py
4 files changed, 55 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/57/61257/1
diff --git a/lib/vdsm/config.py.in b/lib/vdsm/config.py.in
index 1ccb3f0..188b51e 100644
--- a/lib/vdsm/config.py.in
+++ b/lib/vdsm/config.py.in
@@ -392,6 +392,11 @@
'This feature requires a discard support from the storage server. '
'Physical discard operations are supported if the value of '
'/sys/block/<device>/queue/discard_max_bytes is not zero.'),
+
+ ('jobs_autoclear_delay', '60',
+ 'Time to wait (in seconds) before finished jobs are automatically '
+ 'cleared. Once cleared the job can no longer be checked with the '
+ 'Host.getJobs API. To disable autoclear set this to '-1'),
]),
# Section: [addresses]
diff --git a/tests/sdmtestlib.py b/tests/sdmtestlib.py
index 2844a6c..efc5899 100644
--- a/tests/sdmtestlib.py
+++ b/tests/sdmtestlib.py
@@ -43,3 +43,6 @@
assert(vars.job_id == self.id)
if self.exception:
raise self.exception
+
+ def _abort(self):
+ pass
diff --git a/tests/storage_hsm_test.py b/tests/storage_hsm_test.py
index e9e0448..30bc3b3 100644
--- a/tests/storage_hsm_test.py
+++ b/tests/storage_hsm_test.py
@@ -18,6 +18,7 @@
# Refer to the README and COPYING files for full details of the license
#
+import time
import uuid
from contextlib import contextmanager
@@ -25,19 +26,28 @@
from testlib import make_config
from testlib import VdsmTestCase
from testlib import permutations, expandPermutations
+from sdmtestlib import TestingJob, wait_for_job
from storagetestlib import fake_file_env
from storagetestlib import make_file_volume
+from vdsm import jobs
from vdsm import qemuimg
+from vdsm import schedule
from vdsm.storage import constants as sc
from vdsm.storage import exception as se
from storage import hsm
+class FakeTaskManager(object):
+
+ def scheduleJob(self, type, store, task, jobName, func, *args):
+ func(*args)
+
+
class FakeHSM(hsm.HSM):
def __init__(self):
- pass
+ self.taskMng = FakeTaskManager()
@expandPermutations
@@ -117,3 +127,35 @@
make_file_volume(env.sd_manifest, self.SIZE, img_id, vol_id,
vol_format=vol_fmt)
yield env.sd_manifest.produceVolume(img_id, vol_id)
+
+
+@expandPermutations
+class SDMAutoclearTest(VdsmTestCase):
+
+ def run_job(self, delay, error=None, abort=False):
+ conf = make_config([('irs', 'jobs_autoclear_delay', str(delay))])
+ with MonkeyPatchScope([(hsm, 'config', conf)]):
+ scheduler = schedule.Scheduler()
+ scheduler.start()
+ h = FakeHSM()
+ h.set_scheduler(scheduler)
+ job = TestingJob(exception=error)
+ if abort:
+ job.abort()
+ h.sdm_schedule(job)
+ wait_for_job(job)
+ time.sleep(0.1) # Give the scheduler a chance to run
+ return job
+
+ @permutations(((None,), (Exception(),)))
+ def test_autoclear(self, error):
+ job = self.run_job(delay=0, error=error)
+ self.assertRaises(jobs.NoSuchJob, jobs.get, job.id)
+
+ def test_autoclear_aborted(self):
+ job = self.run_job(delay=0, abort=True)
+ self.assertRaises(jobs.NoSuchJob, jobs.get, job.id)
+
+ def test_autoclear_disabled(self):
+ job = self.run_job(delay=-1)
+ self.assertEqual(job.id, jobs.get(job.id).id)
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index a4d4bf3..9c46352 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -3512,6 +3512,10 @@
supported. SDM tasks are managed using the Host Jobs API in jobs.py.
"""
jobs.add(job)
+ delay = config.getint('irs', 'jobs_autoclear_delay')
+ if delay >= 0:
+ job.when_finished(self._scheduler.schedule, delay,
+ partial(jobs.delete, job.id))
self.taskMng.scheduleJob("sdm", None, vars.task,
job.description, job.run)
--
To view, visit https://gerrit.ovirt.org/61257
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I666b65d3a73380d786ac1695e4de5c3c7923effd
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <alitke(a)redhat.com>
7 years, 7 months
Change in vdsm[master]: Pass the Scheduler instance to HSM
by alitke@redhat.com
Adam Litke has uploaded a new change for review.
Change subject: Pass the Scheduler instance to HSM
......................................................................
Pass the Scheduler instance to HSM
In preparation for auto-cleared Jobs, pass the Scheduler instance created at
vdsm startup into the HSM.
Change-Id: I0db5a0dd3f519737a554550efb785d8099d02a6f
Signed-off-by: Adam Litke <alitke(a)redhat.com>
---
M vdsm/storage/hsm.py
M vdsm/vdsm
2 files changed, 12 insertions(+), 6 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/53/61253/1
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index 47d7e76..a4d4bf3 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -338,6 +338,7 @@
:type defExcFun: function
"""
self._ready = False
+ self._scheduler = None
rm.ResourceManager.getInstance().registerNamespace(
STORAGE, rm.SimpleResourceFactory())
self.storage_repository = config.get('irs', 'repository')
@@ -394,6 +395,9 @@
def ready(self):
return self._ready
+ def set_scheduler(self, scheduler):
+ self._scheduler = scheduler
+
@public
def registerDomainStateChangeCallback(self, callbackFunc):
"""
diff --git a/vdsm/vdsm b/vdsm/vdsm
index 497ecb6..3afc777 100755
--- a/vdsm/vdsm
+++ b/vdsm/vdsm
@@ -90,16 +90,18 @@
libvirtconnection.start_event_loop()
try:
- if config.getboolean('irs', 'irs_enable'):
- try:
- irs = Dispatcher(HSM())
- except:
- panic("Error initializing IRS")
-
scheduler = schedule.Scheduler(name="vdsm.Scheduler",
clock=utils.monotonic_time)
scheduler.start()
+ if config.getboolean('irs', 'irs_enable'):
+ try:
+ hsm = HSM()
+ hsm.set_scheduler(scheduler)
+ irs = Dispatcher(hsm)
+ except:
+ panic("Error initializing IRS")
+
from clientIF import clientIF # must import after config is read
cif = clientIF.getInstance(irs, log, scheduler)
--
To view, visit https://gerrit.ovirt.org/61253
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0db5a0dd3f519737a554550efb785d8099d02a6f
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <alitke(a)redhat.com>
7 years, 7 months
Change in vdsm[ovirt-4.0]: build: Remove python 3 test run
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: build: Remove python 3 test run
......................................................................
build: Remove python 3 test run
In 4.0 we don't support Python 3, and there is no need to run tests with
Python 3. Keeping the Python 3 tests only make it hard to backport
changes from master.
This patch removes the Python 3 test run in make check.
Change-Id: Ic6723272a95b407e3fa9ad8e12f595d0b8f0d6a6
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M tests/Makefile.am
1 file changed, 0 insertions(+), 11 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/89/61189/1
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 8b881d8..6204bf9 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -368,14 +368,3 @@
@echo '*** into your environment. Do not submit untested code! ***'
$(top_srcdir)/tests/run_tests_local.sh $(args) crossImportsTests.py
$(top_srcdir)/tests/run_tests_local.sh $(args) $(run_modules)
- if [ "$(PYTHON3_SUPPORT)" == "1" ]; then \
- all_modules=`mktemp`; \
- blacklist=`mktemp`; \
- echo $(run_modules) | tr \ \\n |sort > "$$all_modules"; \
- echo $(blacklist_modules_python3) | tr \ \\n | sort > \
- "$$blacklist"; \
- modules=$$(comm -2 -3 "$$all_modules" "$$blacklist"); \
- rm -f "$$all_modules" "$$blacklist"; \
- PYTHON_EXE="$(PYTHON3)" \
- $(top_srcdir)/tests/run_tests_local.sh "$$modules"; \
- fi
--
To view, visit https://gerrit.ovirt.org/61189
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic6723272a95b407e3fa9ad8e12f595d0b8f0d6a6
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-4.0
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
7 years, 7 months
Change in vdsm[master]: storage: Unify stoage logger name
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: storage: Unify stoage logger name
......................................................................
storage: Unify stoage logger name
We had both "Storage" and "storage" loggers, but configuration was only
for "Storage". Unify all logger names and the configuration to
"storage", matching other loggers names.
We need more work to unify the sub loggers - I'm not touching them now
since I want to move to module level loggers or even subsystem level
loggers instead of class based loggers we have now.
Change-Id: I653c41301393b5450de4ac6dee92b606a5f64838
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M lib/vdsm/storage/clusterlock.py
M lib/vdsm/storage/fileUtils.py
M lib/vdsm/storage/hba.py
M lib/vdsm/storage/misc.py
M lib/vdsm/storage/persistent.py
M lib/vdsm/storage/volumemetadata.py
M vdsm/logger.conf.in
M vdsm/storage/blockSD.py
M vdsm/storage/blockVolume.py
M vdsm/storage/dispatcher.py
M vdsm/storage/fileSD.py
M vdsm/storage/hsm.py
M vdsm/storage/image.py
M vdsm/storage/imageRepository/formatConverter.py
M vdsm/storage/imageSharing.py
M vdsm/storage/iscsi.py
M vdsm/storage/lvm.py
M vdsm/storage/monitor.py
M vdsm/storage/multipath.py
M vdsm/storage/outOfProcess.py
M vdsm/storage/resourceFactories.py
M vdsm/storage/resourceManager.py
M vdsm/storage/sd.py
M vdsm/storage/sdc.py
M vdsm/storage/sdm/volume_artifacts.py
M vdsm/storage/sp.py
M vdsm/storage/spbackends.py
M vdsm/storage/storageServer.py
M vdsm/storage/storage_mailbox.py
M vdsm/storage/task.py
M vdsm/storage/taskManager.py
M vdsm/storage/threadPool.py
M vdsm/storage/volume.py
33 files changed, 67 insertions(+), 67 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/61/61261/1
diff --git a/lib/vdsm/storage/clusterlock.py b/lib/vdsm/storage/clusterlock.py
index 5243a7c..9a2ecee 100644
--- a/lib/vdsm/storage/clusterlock.py
+++ b/lib/vdsm/storage/clusterlock.py
@@ -75,7 +75,7 @@
class SafeLease(object):
- log = logging.getLogger("Storage.SafeLease")
+ log = logging.getLogger("storage.Safelease")
lockUtilPath = config.get('irs', 'lock_util_path')
lockCmd = config.get('irs', 'lock_cmd')
@@ -176,7 +176,7 @@
self._sdUUID)
-initSANLockLog = logging.getLogger("Storage.initSANLock")
+initSANLockLog = logging.getLogger("storage.initSANLock")
def initSANLock(sdUUID, idsPath, leasesPath):
@@ -202,7 +202,7 @@
sanlock.HOST_DEAD: HOST_STATUS_DEAD,
}
- log = logging.getLogger("Storage.SANLock")
+ log = logging.getLogger("storage.SANLock")
_sanlock_fd = None
_sanlock_lock = threading.Lock()
@@ -353,7 +353,7 @@
class LocalLock(object):
- log = logging.getLogger("Storage.LocalLock")
+ log = logging.getLogger("storage.LocalLock")
LVER = 0
diff --git a/lib/vdsm/storage/fileUtils.py b/lib/vdsm/storage/fileUtils.py
index fcd8829..938c641 100644
--- a/lib/vdsm/storage/fileUtils.py
+++ b/lib/vdsm/storage/fileUtils.py
@@ -43,7 +43,7 @@
from vdsm import constants
from vdsm.common.network import address
-log = logging.getLogger('Storage.fileUtils')
+log = logging.getLogger('storage.fileUtils')
MIN_PORT = 1
MAX_PORT = 65535
diff --git a/lib/vdsm/storage/hba.py b/lib/vdsm/storage/hba.py
index 5175a80..4a0a6cf 100644
--- a/lib/vdsm/storage/hba.py
+++ b/lib/vdsm/storage/hba.py
@@ -35,7 +35,7 @@
from vdsm.common import zombiereaper
from vdsm.storage import misc
-log = logging.getLogger("Storage.HBA")
+log = logging.getLogger("storage.HBA")
ISCSI_INITIATOR_NAME = "/etc/iscsi/initiatorname.iscsi"
INITIATOR_NAME = "InitiatorName"
diff --git a/lib/vdsm/storage/misc.py b/lib/vdsm/storage/misc.py
index 5c466a8..6682430 100644
--- a/lib/vdsm/storage/misc.py
+++ b/lib/vdsm/storage/misc.py
@@ -64,7 +64,7 @@
MEGA = 1 << 20
UNLIMITED_THREADS = -1
-log = logging.getLogger('Storage.Misc')
+log = logging.getLogger('storage.Misc')
def namedtuple2dict(nt):
@@ -154,12 +154,12 @@
return result
-execCmdLogger = enableLogSkip(logging.getLogger('Storage.Misc.excCmd'),
+execCmdLogger = enableLogSkip(logging.getLogger('storage.Misc.excCmd'),
ignoreSourceFiles=[__file__],
- logSkipName="Storage.Misc.excCmd")
+ logSkipName="storage.Misc.excCmd")
-execCmd = partial(logskip("Storage.Misc.excCmd")(commands.execCmd),
+execCmd = partial(logskip("storage.Misc.excCmd")(commands.execCmd),
execCmdLogger=execCmdLogger)
@@ -528,7 +528,7 @@
Supporting parameters or exception passing to all functions would
make the code much more complex for no reason.
"""
- _log = logging.getLogger("Storage.SamplingMethod")
+ _log = logging.getLogger("storage.SamplingMethod")
def __init__(self, func):
self.__func = func
@@ -580,7 +580,7 @@
class Event(object):
def __init__(self, name, sync=False):
- self._log = logging.getLogger("Storage.Event.%s" % name)
+ self._log = logging.getLogger("storage.Event.%s" % name)
self.name = name
self._syncRoot = threading.Lock()
self._registrar = {}
diff --git a/lib/vdsm/storage/persistent.py b/lib/vdsm/storage/persistent.py
index 6f708b9..378a888 100644
--- a/lib/vdsm/storage/persistent.py
+++ b/lib/vdsm/storage/persistent.py
@@ -145,7 +145,7 @@
This class provides interface for a generic set of key=value pairs
that can be accessed by any consumer
"""
- log = logging.getLogger("Storage.PersistentDict")
+ log = logging.getLogger("storage.PersistentDict")
@contextmanager
def _accessWrapper(self):
diff --git a/lib/vdsm/storage/volumemetadata.py b/lib/vdsm/storage/volumemetadata.py
index e3b254a..a8d9641 100644
--- a/lib/vdsm/storage/volumemetadata.py
+++ b/lib/vdsm/storage/volumemetadata.py
@@ -29,7 +29,7 @@
class VolumeMetadata(object):
- log = logging.getLogger('Storage.VolumeMetadata')
+ log = logging.getLogger('storage.VolumeMetadata')
def __init__(self, domain, image, puuid, size, format,
type, voltype, disktype, description="",
diff --git a/vdsm/logger.conf.in b/vdsm/logger.conf.in
index 53aa517..198c9b8 100644
--- a/vdsm/logger.conf.in
+++ b/vdsm/logger.conf.in
@@ -1,5 +1,5 @@
[loggers]
-keys=root,vds,Storage,virt,ovirt_hosted_engine_ha,ovirt_hosted_engine_ha_config,IOProcess,connectivity
+keys=root,vds,storage,virt,ovirt_hosted_engine_ha,ovirt_hosted_engine_ha_config,IOProcess,connectivity
[handlers]
keys=console,syslog,logfile,connlogfile
@@ -18,10 +18,10 @@
qualname=vds
propagate=0
-[logger_Storage]
+[logger_storage]
level=DEBUG
handlers=logfile
-qualname=Storage
+qualname=storage
propagate=0
[logger_ovirt_hosted_engine_ha]
diff --git a/vdsm/storage/blockSD.py b/vdsm/storage/blockSD.py
index 687dcaa..6a8adcc 100644
--- a/vdsm/storage/blockSD.py
+++ b/vdsm/storage/blockSD.py
@@ -69,7 +69,7 @@
MASTERLV_SIZE = "1024" # In MiB = 2 ** 20 = 1024 ** 2 => 1GiB
BlockSDVol = namedtuple("BlockSDVol", "name, image, parent")
-log = logging.getLogger("Storage.BlockSD")
+log = logging.getLogger("storage.BlockSD")
# FIXME: Make this calculated from something logical
RESERVED_METADATA_SIZE = 40 * (2 ** 20)
@@ -256,7 +256,7 @@
class VGTagMetadataRW(object):
- log = logging.getLogger("Storage.Metadata.VGTagMetadataRW")
+ log = logging.getLogger("storage.Metadata.VGTagMetadataRW")
METADATA_TAG_PREFIX = "MDT_"
METADATA_TAG_PREFIX_LEN = len(METADATA_TAG_PREFIX)
@@ -299,7 +299,7 @@
"""
Block Storage Domain metadata implementation
"""
- log = logging.getLogger("Storage.Metadata.LvMetadataRW")
+ log = logging.getLogger("storage.Metadata.LvMetadataRW")
def __init__(self, vgName, lvName, offset, size):
self._size = size
diff --git a/vdsm/storage/blockVolume.py b/vdsm/storage/blockVolume.py
index 9651314..357a232 100644
--- a/vdsm/storage/blockVolume.py
+++ b/vdsm/storage/blockVolume.py
@@ -61,7 +61,7 @@
# - 2..100 (Unassigned)
RESERVED_LEASES = 100
-log = logging.getLogger('Storage.Volume')
+log = logging.getLogger('storage.Volume')
rmanager = rm.ResourceManager.getInstance()
diff --git a/vdsm/storage/dispatcher.py b/vdsm/storage/dispatcher.py
index e2f0cb1..ab26986 100644
--- a/vdsm/storage/dispatcher.py
+++ b/vdsm/storage/dispatcher.py
@@ -35,7 +35,7 @@
class Dispatcher(object):
- log = logging.getLogger('Storage.Dispatcher')
+ log = logging.getLogger('storage.Dispatcher')
STATUS_OK = {'status': {'code': 0, 'message': "OK"}}
STATUS_ERROR = {'status': {'code': 100, 'message': "ERROR"}}
diff --git a/vdsm/storage/fileSD.py b/vdsm/storage/fileSD.py
index d3e0c29..bddb3bf 100644
--- a/vdsm/storage/fileSD.py
+++ b/vdsm/storage/fileSD.py
@@ -95,7 +95,7 @@
oop.getProcessPool(sdUUID).directTouch(testFilePath)
except OSError as e:
if e.errno == errno.EINVAL:
- log = logging.getLogger("Storage.fileSD")
+ log = logging.getLogger("storage.fileSD")
log.error("Underlying file system doesn't support"
"direct IO")
raise se.StorageDomainTargetUnsupported()
@@ -737,7 +737,7 @@
def scanDomains(pattern="*"):
- log = logging.getLogger("Storage.scanDomains")
+ log = logging.getLogger("storage.scanDomains")
mntList = _getMountsList(pattern)
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index 47d7e76..1860232 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -271,7 +271,7 @@
saved on the disk.
"""
pools = {}
- log = logging.getLogger('Storage.HSM')
+ log = logging.getLogger('storage.HSM')
@classmethod
def validateSdUUID(cls, sdUUID):
diff --git a/vdsm/storage/image.py b/vdsm/storage/image.py
index 6f83c1e..3ffb142 100644
--- a/vdsm/storage/image.py
+++ b/vdsm/storage/image.py
@@ -42,7 +42,7 @@
import resourceFactories
import resourceManager as rm
-log = logging.getLogger('Storage.Image')
+log = logging.getLogger('storage.Image')
rmanager = rm.ResourceManager.getInstance()
# Disk type
@@ -112,7 +112,7 @@
""" Actually represents a whole virtual disk.
Consist from chain of volumes.
"""
- log = logging.getLogger('Storage.Image')
+ log = logging.getLogger('storage.Image')
_fakeTemplateLock = threading.Lock()
@classmethod
diff --git a/vdsm/storage/imageRepository/formatConverter.py b/vdsm/storage/imageRepository/formatConverter.py
index aaa70ac..3d6e0ff 100644
--- a/vdsm/storage/imageRepository/formatConverter.py
+++ b/vdsm/storage/imageRepository/formatConverter.py
@@ -31,7 +31,7 @@
def __convertDomainMetadataToTags(domain, targetVersion):
- log = logging.getLogger('Storage.DomainMetadataToTags')
+ log = logging.getLogger('storage.DomainMetadataToTags')
newMetadata = blockSD.TagBasedSDMetadata(domain.sdUUID)
oldMetadata = domain._metadata
@@ -73,7 +73,7 @@
def v2DomainConverter(repoPath, hostId, domain, isMsd):
- log = logging.getLogger('Storage.v2DomainConverter')
+ log = logging.getLogger('storage.v2DomainConverter')
targetVersion = 2
if domain.getStorageType() in sd.BLOCK_DOMAIN_TYPES:
@@ -88,7 +88,7 @@
def v3DomainConverter(repoPath, hostId, domain, isMsd):
- log = logging.getLogger('Storage.v3DomainConverter')
+ log = logging.getLogger('storage.v3DomainConverter')
targetVersion = 3
currentVersion = domain.getVersion()
diff --git a/vdsm/storage/imageSharing.py b/vdsm/storage/imageSharing.py
index b8c3240..ae2d140 100644
--- a/vdsm/storage/imageSharing.py
+++ b/vdsm/storage/imageSharing.py
@@ -25,7 +25,7 @@
from vdsm.storage import curlImgWrap
from vdsm.storage import exception as se
-log = logging.getLogger("Storage.ImageSharing")
+log = logging.getLogger("storage.ImageSharing")
# Time to wait from finishing writing data to dd, until dd exists,
# Ensure that we don't keep the task active forever if dd cannot
# access the storage.
diff --git a/vdsm/storage/iscsi.py b/vdsm/storage/iscsi.py
index d12fd29..4df844c 100644
--- a/vdsm/storage/iscsi.py
+++ b/vdsm/storage/iscsi.py
@@ -52,7 +52,7 @@
_iscsiadmTransactionLock = RLock()
-log = logging.getLogger('Storage.ISCSI')
+log = logging.getLogger('storage.ISCSI')
def getDevIscsiSessionId(dev):
diff --git a/vdsm/storage/lvm.py b/vdsm/storage/lvm.py
index 3d3c31a..5bce167 100644
--- a/vdsm/storage/lvm.py
+++ b/vdsm/storage/lvm.py
@@ -46,7 +46,7 @@
import multipath
from vdsm.config import config
-log = logging.getLogger("Storage.LVM")
+log = logging.getLogger("storage.LVM")
LVM_DEFAULT_TTL = 100
diff --git a/vdsm/storage/monitor.py b/vdsm/storage/monitor.py
index 607f8af..aa55e55 100644
--- a/vdsm/storage/monitor.py
+++ b/vdsm/storage/monitor.py
@@ -31,7 +31,7 @@
from .sdc import sdCache
-log = logging.getLogger('Storage.Monitor')
+log = logging.getLogger('storage.Monitor')
class Status(object):
@@ -144,7 +144,7 @@
# NOTE: This must be used in asynchronous mode to prevent blocking of
# the checker event loop thread.
self.onDomainStateChange = misc.Event(
- "Storage.DomainMonitor.onDomainStateChange", sync=False)
+ "storage.DomainMonitor.onDomainStateChange", sync=False)
self._checker = check.CheckService()
self._checker.start()
diff --git a/vdsm/storage/multipath.py b/vdsm/storage/multipath.py
index 27f720e..d7b5521 100644
--- a/vdsm/storage/multipath.py
+++ b/vdsm/storage/multipath.py
@@ -49,7 +49,7 @@
TOXIC_CHARS = '()*+?|^$.\\'
-log = logging.getLogger("Storage.Multipath")
+log = logging.getLogger("storage.Multipath")
_SCSI_ID = utils.CommandPath("scsi_id",
"/usr/lib/udev/scsi_id", # Fedora, EL7
diff --git a/vdsm/storage/outOfProcess.py b/vdsm/storage/outOfProcess.py
index c6b2cee..4c3e61a 100644
--- a/vdsm/storage/outOfProcess.py
+++ b/vdsm/storage/outOfProcess.py
@@ -49,7 +49,7 @@
elapsed_time = lambda: os.times()[4]
-log = logging.getLogger('Storage.oop')
+log = logging.getLogger('storage.oop')
def stop():
diff --git a/vdsm/storage/resourceFactories.py b/vdsm/storage/resourceFactories.py
index 90c4512..255df6a 100644
--- a/vdsm/storage/resourceFactories.py
+++ b/vdsm/storage/resourceFactories.py
@@ -36,7 +36,7 @@
rmanager = rm.ResourceManager.getInstance()
-log = logging.getLogger('Storage.ResourcesFactories')
+log = logging.getLogger('storage.ResourcesFactories')
class LvmActivation(object):
diff --git a/vdsm/storage/resourceManager.py b/vdsm/storage/resourceManager.py
index 8fb2e24..0b5fcf5 100644
--- a/vdsm/storage/resourceManager.py
+++ b/vdsm/storage/resourceManager.py
@@ -171,7 +171,7 @@
"""
Internal request object, don't use directly
"""
- _log = logging.getLogger("Storage.ResourceManager.Request")
+ _log = logging.getLogger("storage.ResourceManager.Request")
namespace = property(lambda self: self._namespace)
name = property(lambda self: self._name)
fullName = property(lambda self: "%s.%s" % (self._namespace, self._name))
@@ -193,7 +193,7 @@
# Because findCaller is expensive. We make sure it wll be printed
# before calculating it
- if logging.getLogger("Storage.ResourceManager.ResourceRef").\
+ if logging.getLogger("storage.ResourceManager.ResourceRef").\
isEnabledFor(logging.WARN):
createdAt = misc.findCaller(ignoreSourceFiles=[__file__],
logSkipName="ResourceManager")
@@ -269,7 +269,7 @@
This object will auto release the referenced resource unless autorelease
is set to `False`
"""
- _log = logging.getLogger("Storage.ResourceManager.ResourceRef")
+ _log = logging.getLogger("storage.ResourceManager.ResourceRef")
namespace = property(lambda self: self._namespace)
name = property(lambda self: self._name)
fullName = property(lambda self: "%s.%s" % (self._namespace, self._name))
@@ -359,7 +359,7 @@
This class is a singleton. use `getInstance()` to get the global instance
"""
- _log = logging.getLogger("Storage.ResourceManager")
+ _log = logging.getLogger("storage.ResourceManager")
_namespaceValidator = re.compile(r"^[\w\d_-]+$")
_resourceNameValidator = re.compile(r"^[^\s.]+$")
@@ -733,7 +733,7 @@
class Owner(object):
- log = logging.getLogger('Storage.ResourceManager.Owner')
+ log = logging.getLogger('storage.ResourceManager.Owner')
def __init__(self, ownerobject, raiseonfailure=False):
self.ownerobject = ownerobject
diff --git a/vdsm/storage/sd.py b/vdsm/storage/sd.py
index b84abbd..f502ebe 100644
--- a/vdsm/storage/sd.py
+++ b/vdsm/storage/sd.py
@@ -295,7 +295,7 @@
class StorageDomainManifest(object):
- log = logging.getLogger("Storage.StorageDomainManifest")
+ log = logging.getLogger("storage.StorageDomainManifest")
# version: clusterLockClass
_domainLockTable = {
@@ -489,7 +489,7 @@
class StorageDomain(object):
- log = logging.getLogger("Storage.StorageDomain")
+ log = logging.getLogger("storage.StorageDomain")
storage_repository = config.get('irs', 'repository')
mdBackupVersions = config.get('irs', 'md_backup_versions')
mdBackupDir = config.get('irs', 'md_backup_dir')
diff --git a/vdsm/storage/sdc.py b/vdsm/storage/sdc.py
index 7e5ddd1..4df521c 100644
--- a/vdsm/storage/sdc.py
+++ b/vdsm/storage/sdc.py
@@ -59,7 +59,7 @@
the current system.
"""
- log = logging.getLogger('Storage.StorageDomainCache')
+ log = logging.getLogger('storage.StorageDomainCache')
STORAGE_UPDATED = 0
STORAGE_STALE = 1
diff --git a/vdsm/storage/sdm/volume_artifacts.py b/vdsm/storage/sdm/volume_artifacts.py
index cf010e6..d12f1b0 100644
--- a/vdsm/storage/sdm/volume_artifacts.py
+++ b/vdsm/storage/sdm/volume_artifacts.py
@@ -61,7 +61,7 @@
class VolumeArtifacts(object):
- log = logging.getLogger('Storage.VolumeArtifacts')
+ log = logging.getLogger('storage.VolumeArtifacts')
def __init__(self, sd_manifest, img_id, vol_id):
"""
@@ -179,7 +179,7 @@
- create new volume -> change state to GARBAGE
- destroy this volume -> change state to GARBAGE
"""
- log = logging.getLogger('Storage.FileVolumeArtifacts')
+ log = logging.getLogger('storage.FileVolumeArtifacts')
def __init__(self, sd_manifest, img_id, vol_id):
super(FileVolumeArtifacts, self).__init__(sd_manifest, img_id,
@@ -351,7 +351,7 @@
- create new volume -> change state to GARBAGE
- destroy this volume -> change state to GARBAGE
"""
- log = logging.getLogger('Storage.BlockVolumeArtifacts')
+ log = logging.getLogger('storage.BlockVolumeArtifacts')
def __init__(self, sd_manifest, img_id, vol_id):
self.vol_class = sd_manifest.getVolumeClass()
diff --git a/vdsm/storage/sp.py b/vdsm/storage/sp.py
index c9b8ddd..d63ba6f 100644
--- a/vdsm/storage/sp.py
+++ b/vdsm/storage/sp.py
@@ -69,7 +69,7 @@
any heavy lifting activities until the time it is really needed.
'''
- log = logging.getLogger('Storage.StoragePool')
+ log = logging.getLogger('storage.StoragePool')
storage_repository = config.get('irs', 'repository')
lvExtendPolicy = config.get('irs', 'vol_extend_policy')
diff --git a/vdsm/storage/spbackends.py b/vdsm/storage/spbackends.py
index 505a988..f8b3150 100644
--- a/vdsm/storage/spbackends.py
+++ b/vdsm/storage/spbackends.py
@@ -200,7 +200,7 @@
__slots__ = ('pool',)
- log = logging.getLogger('Storage.StoragePoolDiskBackend')
+ log = logging.getLogger('storage.StoragePoolDiskBackend')
def __init__(self, pool):
self.pool = weakref.proxy(pool)
@@ -403,7 +403,7 @@
__slots__ = ('pool', 'masterVersion', 'domainsMap')
- log = logging.getLogger('Storage.StoragePoolMemoryBackend')
+ log = logging.getLogger('storage.StoragePoolMemoryBackend')
def __init__(self, pool, masterVersion, domainsMap):
self.pool = weakref.proxy(pool)
diff --git a/vdsm/storage/storageServer.py b/vdsm/storage/storageServer.py
index 05f69e7..50e67af 100644
--- a/vdsm/storage/storageServer.py
+++ b/vdsm/storage/storageServer.py
@@ -183,7 +183,7 @@
CGROUP = None
DIR = ""
- log = logging.getLogger("Storage.StorageServer.MountConnection")
+ log = logging.getLogger("storage.StorageServer.MountConnection")
localPathBase = "/tmp"
@property
@@ -472,7 +472,7 @@
class IscsiConnection(object):
- log = logging.getLogger("Storage.Server.ISCSI")
+ log = logging.getLogger("storage.Server.ISCSI")
class Mismatch(Exception):
@@ -689,7 +689,7 @@
class ConnectionAliasRegistrar(object):
- log = logging.getLogger("Storage.StorageServer.ConnectionAliasRegistrar")
+ log = logging.getLogger("storage.StorageServer.ConnectionAliasRegistrar")
def __init__(self, persistDir):
self._aliases = {}
@@ -792,7 +792,7 @@
class ConnectionMonitor(object):
- _log = logging.getLogger("Storage.ConnectionMonitor")
+ _log = logging.getLogger("storage.ConnectionMonitor")
TAG = "managed"
diff --git a/vdsm/storage/storage_mailbox.py b/vdsm/storage/storage_mailbox.py
index 64cccac..4853af7 100644
--- a/vdsm/storage/storage_mailbox.py
+++ b/vdsm/storage/storage_mailbox.py
@@ -86,7 +86,7 @@
class SPM_Extend_Message:
- log = logging.getLogger('Storage.SPM.Messages.Extend')
+ log = logging.getLogger('storage.SPM.Messages.Extend')
def __init__(self, volumeData, newSize, callbackFunction=None):
@@ -178,7 +178,7 @@
class HSM_Mailbox:
- log = logging.getLogger('Storage.Mailbox.HSM')
+ log = logging.getLogger('storage.Mailbox.HSM')
def __init__(self, hostID, poolID, monitorInterval=2):
self._hostID = str(hostID)
@@ -229,7 +229,7 @@
class HSM_MailMonitor(object):
- log = logging.getLogger('Storage.MailBox.HsmMailMonitor')
+ log = logging.getLogger('storage.MailBox.HsmMailMonitor')
def __init__(self, inbox, outbox, hostID, queue, monitorInterval):
# Save arguments
@@ -514,7 +514,7 @@
class SPM_MailMonitor:
- log = logging.getLogger('Storage.MailBox.SpmMailMonitor')
+ log = logging.getLogger('storage.MailBox.SpmMailMonitor')
def registerMessageType(self, messageType, callback):
self._messageTypes[messageType] = callback
diff --git a/vdsm/storage/task.py b/vdsm/storage/task.py
index c9a5b1b..ce313d5 100644
--- a/vdsm/storage/task.py
+++ b/vdsm/storage/task.py
@@ -456,7 +456,7 @@
"metadataVersion": int
}
- log = logging.getLogger('Storage.TaskManager.Task')
+ log = logging.getLogger('storage.TaskManager.Task')
def __init__(self, id, name="", tag="",
recovery=TaskRecoveryType.none,
diff --git a/vdsm/storage/taskManager.py b/vdsm/storage/taskManager.py
index d2ec32e..3696229 100644
--- a/vdsm/storage/taskManager.py
+++ b/vdsm/storage/taskManager.py
@@ -30,7 +30,7 @@
class TaskManager:
- log = logging.getLogger('Storage.TaskManager')
+ log = logging.getLogger('storage.TaskManager')
def __init__(self,
tpSize=config.getint('irs', 'thread_pool_size'),
diff --git a/vdsm/storage/threadPool.py b/vdsm/storage/threadPool.py
index 1ac10c9..e2ecf74 100644
--- a/vdsm/storage/threadPool.py
+++ b/vdsm/storage/threadPool.py
@@ -23,7 +23,7 @@
accepts tasks that will be dispatched to the next available
thread."""
- log = logging.getLogger('Storage.ThreadPool')
+ log = logging.getLogger('storage.ThreadPool')
def __init__(self, numThreads, waitTimeout=3, maxTasks=100):
@@ -173,7 +173,7 @@
""" Pooled thread class. """
- log = logging.getLogger('Storage.ThreadPool.WorkerThread')
+ log = logging.getLogger('storage.ThreadPool.WorkerThread')
def __init__(self, pool):
diff --git a/vdsm/storage/volume.py b/vdsm/storage/volume.py
index b1cf15a..4402813 100644
--- a/vdsm/storage/volume.py
+++ b/vdsm/storage/volume.py
@@ -43,7 +43,7 @@
DOMAIN_MNT_POINT = 'mnt'
-log = logging.getLogger('Storage.Volume')
+log = logging.getLogger('storage.Volume')
def getBackingVolumePath(imgUUID, volUUID):
@@ -62,7 +62,7 @@
class VolumeManifest(object):
- log = logging.getLogger('Storage.VolumeManifest')
+ log = logging.getLogger('storage.VolumeManifest')
def __init__(self, repoPath, sdUUID, imgUUID, volUUID):
self.repoPath = repoPath
@@ -490,7 +490,7 @@
class Volume(object):
- log = logging.getLogger('Storage.Volume')
+ log = logging.getLogger('storage.Volume')
manifestClass = VolumeManifest
def __init__(self, manifest):
--
To view, visit https://gerrit.ovirt.org/61261
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I653c41301393b5450de4ac6dee92b606a5f64838
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
7 years, 7 months
Change in vdsm[master]: yajsonrpc: switch to concurrent.thread()
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: yajsonrpc: switch to concurrent.thread()
......................................................................
yajsonrpc: switch to concurrent.thread()
This patch:
1. replaces good usages of threading.Thread() with
more modern concurrent.thread()
2. replaces bad usages of threading.Thread() - inheritance
with composition, leveraging concurrent.thread()
there are no intended changes in behaviour.
Change-Id: I42841c79e70755c0be5455949e33b84006930af0
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M lib/yajsonrpc/stompreactor.py
1 file changed, 3 insertions(+), 4 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/62/61462/1
diff --git a/lib/yajsonrpc/stompreactor.py b/lib/yajsonrpc/stompreactor.py
index 509e251..9f4ad30 100644
--- a/lib/yajsonrpc/stompreactor.py
+++ b/lib/yajsonrpc/stompreactor.py
@@ -18,8 +18,8 @@
from collections import deque
from uuid import uuid4
import functools
-import threading
+from vdsm import concurrent
from vdsm import utils
from vdsm.config import config
from vdsm.compat import json
@@ -586,9 +586,8 @@
reactor = Reactor()
def start():
- thread = threading.Thread(target=reactor.process_requests,
- name='Client %s:%s' % (host, port))
- thread.setDaemon(True)
+ thread = concurrent.thread(reactor.process_requests,
+ name='Client %s:%s' % (host, port))
thread.start()
client = StompClient(utils.create_connected_socket(host, port, sslctx),
--
To view, visit https://gerrit.ovirt.org/61462
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I42841c79e70755c0be5455949e33b84006930af0
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
7 years, 7 months
Change in vdsm[master]: spec: Require sanlock version handling EINTR
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: spec: Require sanlock version handling EINTR
......................................................................
spec: Require sanlock version handling EINTR
libsanlock was not handling EINTR, causing failures in sanlock calls if vdsm
received a signal while libsnalock was block in a syscall. A typical case is
when child process terminates and vdsm receive a SIGCHLD.
When this happens, the vdsm operation fails with this error:
SanlockException: (4, 'Sanlock ...', 'Interrupted system call')
The fix is not available yet on Fedora, so we only update to require the
current version, as we used to require an ancient version which is not relevant
for many releases.
Change-Id: I1203ad58f0f0ed1789a1e85d7f0b364891ef5864
Bug-Url: https://bugzilla.redhat.com/1356676
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M vdsm.spec.in
1 file changed, 11 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/00/61200/1
diff --git a/vdsm.spec.in b/vdsm.spec.in
index d1f91cf..63c1e76 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -187,7 +187,17 @@
Requires: iscsi-initiator-utils >= 6.2.0.873-21
%endif
-Requires: sanlock >= 2.8-2, sanlock-python
+# sanlock
+
+%if 0%{rhel}
+Requires: sanlock >= sanlock-3.2.4-3.el7_2
+%endif
+
+%if 0%{fedora}
+Requires: sanlock >= 3.3.0-2
+%endif
+
+Requires: sanlock-python
# device-mapper-multipath
--
To view, visit https://gerrit.ovirt.org/61200
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1203ad58f0f0ed1789a1e85d7f0b364891ef5864
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
7 years, 7 months
Change in vdsm[master]: vdsm: add eventfd and EventFile synchronization
by Federico Simoncelli
Federico Simoncelli has uploaded a new change for review.
Change subject: vdsm: add eventfd and EventFile synchronization
......................................................................
vdsm: add eventfd and EventFile synchronization
Change-Id: I0d237f13c42b1f4505c90d30c6d3c3ecbd1e9fa7
Signed-off-by: Federico Simoncelli <fsimonce(a)redhat.com>
---
M lib/vdsm/Makefile.am
A lib/vdsm/eventfd.py
M tests/Makefile.am
A tests/eventfdTests.py
4 files changed, 251 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/87/33687/1
diff --git a/lib/vdsm/Makefile.am b/lib/vdsm/Makefile.am
index 4bebf28..e712cad 100644
--- a/lib/vdsm/Makefile.am
+++ b/lib/vdsm/Makefile.am
@@ -25,6 +25,7 @@
__init__.py \
compat.py \
define.py \
+ eventfd.py \
exception.py \
ipwrapper.py \
libvirtconnection.py \
diff --git a/lib/vdsm/eventfd.py b/lib/vdsm/eventfd.py
new file mode 100644
index 0000000..b2a7084
--- /dev/null
+++ b/lib/vdsm/eventfd.py
@@ -0,0 +1,140 @@
+#
+# Copyright 2014 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+
+"""\
+This module provides the support for eventfd(2).
+
+More information about eventfd and usage examples can be found in the
+eventfd(2) man page.
+
+The EventFile class provides a single synchronization object exposing
+the python Event interface and associated eventfds.
+
+The eventfd() context manager returns a file descriptor that can be
+used to provide the event notice to select, poll and epoll, e.g.
+
+ import os
+ import sys
+ import select
+ import threading
+ import time
+ from vdsm.eventfd import EventFile, DATASIZE
+
+ e = EventFile()
+ p = select.epoll()
+
+ threading.Timer(5, e.set).start()
+
+ with e.eventfd() as efd:
+ p.register(efd, select.EPOLLIN)
+ p.register(sys.stdin.fileno(), select.EPOLLIN)
+
+ print "Echoing lines until event is received"
+ event_received = False
+
+ while not event_received:
+ for fileno, event in p.poll():
+ if not event & select.EPOLLIN:
+ continue
+
+ if fileno == efd:
+ os.read(efd, DATASIZE)
+ event_received = True
+ elif fileno == sys.stdin.fileno():
+ print os.read(sys.stdin.fileno(), 1024),
+
+ print "Event received!"
+
+
+The Event set() semantic is preserved in the eventfd context manager:
+if the event is set then the eventfd already contains the notification.
+This is both to maintain the semantic and to avoid possible races as:
+
+ if not e.is_set():
+ with e.eventfd() as efd:
+ ...
+"""
+
+import os
+import ctypes
+import threading
+
+from contextlib import contextmanager
+
+_libc = ctypes.CDLL('libc.so.6', use_errno=True)
+
+EFD_NONBLOCK = os.O_NONBLOCK
+EFD_CLOEXEC = 02000000 # os.O_CLOEXEC in python 3.3
+EFD_SEMAPHORE = 00000001
+
+DATASIZE = ctypes.sizeof(ctypes.c_ulonglong)
+
+
+def eventfd(initval, flags):
+ return _libc.eventfd(initval, flags)
+
+
+class EventFile(object):
+ def __init__(self, event=None):
+ self.__lock = threading.Lock()
+ self.__fds = set()
+ self.__event = event or threading.Event()
+
+ @staticmethod
+ def __fire_event(fd):
+ os.write(fd, ctypes.c_ulonglong(1))
+
+ def open_eventfd(self):
+ with self.__lock:
+ fd = eventfd(0, 0)
+
+ self.__fds.add(fd)
+
+ if self.__event.is_set():
+ self.__fire_event(fd)
+
+ return fd
+
+ @contextmanager
+ def eventfd(self):
+ fd = self.open_eventfd()
+
+ yield fd
+
+ with self.__lock:
+ self.__fds.remove(fd)
+ os.close(fd)
+
+ def isSet(self):
+ return self.__event.isSet()
+
+ is_set = isSet
+
+ def set(self):
+ with self.__lock:
+ self.__event.set()
+ for fd in self.__fds:
+ self.__fire_event(fd)
+
+ def clear(self):
+ self.__event.clear()
+
+ def wait(self, timeout=None, balancing=True):
+ self.__event.wait(timeout)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 449d7b1..120712e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -31,6 +31,7 @@
clientifTests.py \
configNetworkTests.py \
domainMonitorTests.py \
+ eventfdTests.py \
fileVolumeTests.py \
fileUtilTests.py \
fuserTests.py \
diff --git a/tests/eventfdTests.py b/tests/eventfdTests.py
new file mode 100644
index 0000000..be15248
--- /dev/null
+++ b/tests/eventfdTests.py
@@ -0,0 +1,109 @@
+#
+# Copyright 2014 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+
+import os
+import select
+from vdsm.eventfd import EventFile, DATASIZE
+from nose.tools import timed, raises, TimeExpired
+
+TEST_TIMEOUT = 1
+WAIT_TIMEOUT = 2
+
+
+def test_set():
+ e = EventFile()
+ e.set()
+ assert e.is_set()
+ assert e.isSet()
+
+
+def text_clear():
+ e = EventFile()
+ e.set()
+ assert e.is_set()
+ e.clear()
+ assert not e.is_set()
+
+
+@timed(TEST_TIMEOUT)
+def test_wait_set():
+ e = EventFile()
+ e.set()
+ e.wait(WAIT_TIMEOUT)
+
+
+@raises(TimeExpired)
+@timed(TEST_TIMEOUT)
+def test_wait_noset():
+ e = EventFile()
+ e.wait(WAIT_TIMEOUT)
+
+
+@timed(TEST_TIMEOUT)
+def test_eventfd_earlyset():
+ e = EventFile()
+ e.set()
+ with e.eventfd() as fd:
+ assert len(__select_and_read(fd)) == DATASIZE
+
+
+@timed(TEST_TIMEOUT)
+def test_eventfd_lateset():
+ e = EventFile()
+ with e.eventfd() as fd:
+ e.set()
+ assert len(__select_and_read(fd)) == DATASIZE
+
+
+@raises(TimeExpired)
+@timed(TEST_TIMEOUT)
+def test_eventfd_noset():
+ e = EventFile()
+ with e.eventfd() as fd:
+ assert len(__select_and_read(fd)) != DATASIZE
+
+
+@timed(TEST_TIMEOUT)
+def test_eventfd_multiple():
+ e = EventFile()
+ e.set()
+ with e.eventfd() as fd1:
+ assert len(__select_and_read(fd1)) == DATASIZE
+ with e.eventfd() as fd2:
+ assert len(__select_and_read(fd2)) == DATASIZE
+ with e.eventfd() as fd3:
+ assert len(__select_and_read(fd3)) == DATASIZE
+
+
+@raises(TimeExpired)
+@timed(TEST_TIMEOUT)
+def test_eventfd_clear():
+ e = EventFile()
+ e.set()
+ e.clear()
+ with e.eventfd() as fd:
+ assert len(__select_and_read(fd)) != DATASIZE
+
+
+def __select_and_read(fd):
+ rd, wr, ex = select.select((fd,), (), (), WAIT_TIMEOUT)
+ if fd in rd:
+ return os.read(fd, DATASIZE)
+ return ''
--
To view, visit http://gerrit.ovirt.org/33687
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0d237f13c42b1f4505c90d30c6d3c3ecbd1e9fa7
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <fsimonce(a)redhat.com>
7 years, 7 months
Change in vdsm[master]: yml: schema validation tests
by Piotr Kliczewski
Piotr Kliczewski has uploaded a new change for review.
Change subject: yml: schema validation tests
......................................................................
yml: schema validation tests
Change-Id: I2420908ebb39136339a5a52daf12f359836c5291
Signed-off-by: Piotr Kliczewski <piotr.kliczewski(a)gmail.com>
---
M tests/vdsmapi_test.py
1 file changed, 216 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/71/60071/1
diff --git a/tests/vdsmapi_test.py b/tests/vdsmapi_test.py
index 9ae1668..30f5c9a 100644
--- a/tests/vdsmapi_test.py
+++ b/tests/vdsmapi_test.py
@@ -458,3 +458,219 @@
sub_id = '|virt|VM_status|426aef82-ea1d-4442-91d3-fd876540e0f0'
_events_schema.events_schema().verify_event_params(sub_id, params)
+
+ def test_connect_server(self):
+ params = {u'connectionParams':
+ [{u'id': u'a454a600-b3b7-46ea-8032-717deedcd219',
+ u'connection': u'10.35.0.99',
+ u'iqn': u'iqn.2003-01.org.dumbo.target1',
+ u'user': u'',
+ u'tpgt': u'1',
+ u'password': '********',
+ u'port': u'3260'},
+ {u'id': u'48b086ae-6d80-4d6f-96ac-43c6ffcaab3e',
+ u'connection': u'10.35.0.99',
+ u'iqn': u'iqn.2003-01.org.dumbo.target2',
+ u'user': u'',
+ u'tpgt': u'1',
+ u'password': '********',
+ u'port': u'3260'}],
+ u'storagepoolID': u'636d9c59-f7ba-4115-87a1-44d6563a9610',
+ u'domainType': 3}
+
+ _schema.schema().verify_args(
+ vdsmapi.MethodRep('StoragePool', 'connectStorageServer'),
+ params)
+
+ def test_sp_connect(self):
+ params = {u'masterVersion': 33,
+ u'domainDict':
+ {u'0900c0cd-8422-497a-85c5-1bb34b2b6b65': u'active',
+ u'794dc113-315f-43e3-ae47-0b7b1bf56427': u'active',
+ u'1d8235ee-c2ce-4c06-abd5-63b655fd66c5': u'active'},
+ u'storagepoolID': u'636d9c59-f7ba-4115-87a1-44d6563a9610',
+ u'scsiKey': u'636d9c59-f7ba-4115-87a1-44d6563a9610',
+ u'masterSdUUID': u'3d4accf7-74af-4ea0-b59b-eb9f10eedb83',
+ u'hostID': 1}
+
+ _schema.schema().verify_args(
+ vdsmapi.MethodRep('StoragePool', 'connect'), params)
+
+ def test_host_list_caps(self):
+ ret = {'net_eth0_52_54_00_56_00_39':
+ {'params': {'capability': 'net',
+ 'interface': 'eth0',
+ 'parent': 'pci_0000_00_03_0',
+ 'is_assignable': 'true'}},
+ 'computer':
+ {'params': {'capability': 'system',
+ 'is_assignable': 'true',
+ 'product': 'Standard PC (i440FX + PIIX, 1996)'}},
+ 'usb_1_1_1_0':
+ {'params': {'capability': 'usb',
+ 'is_assignable': 'true',
+ 'driver': 'usbhid',
+ 'parent': 'usb_1_1'}},
+ 'scsi_target7_0_0':
+ {'params': {'capability': 'scsi_target',
+ 'is_assignable': 'true',
+ 'parent': 'scsi_host7'}},
+ 'usb_usb1':
+ {'params': {'product': '2.0 root hub',
+ 'vendor': 'Linux Foundation',
+ 'product_id': '0x0002',
+ 'parent': 'pci_0000_00_05_7',
+ 'vendor_id': '0x1d6b',
+ 'driver': 'usb',
+ 'capability': 'usb_device',
+ 'is_assignable': 'true',
+ 'address': {'device': '1', 'bus': '1'}}},
+ 'pci_0000_00_02_0':
+ {'params': {'product': 'QXL paravirtual graphic card',
+ 'vendor': 'Red Hat, Inc.',
+ 'product_id': '0x0100',
+ 'parent': 'computer',
+ 'vendor_id': '0x1b36',
+ 'driver': 'qxl',
+ 'capability': 'pci',
+ 'is_assignable': 'true',
+ 'address': {'slot': '2',
+ 'bus': '0',
+ 'domain': '0',
+ 'function': '0'}}},
+ 'scsi_5_0_0_18':
+ {'params': {'product': 'target1-18',
+ 'vendor': 'LIO-ORG',
+ 'parent': 'scsi_target5_0_0',
+ 'driver': 'sd',
+ 'capability': 'scsi',
+ 'is_assignable': 'true',
+ 'udev_path': '/dev/sg2',
+ 'address': {'bus': '0',
+ 'host': '5',
+ 'target': '0',
+ 'lun': '18'}}},
+ 'scsi_host5':
+ {'params': {'capability': 'scsi_host',
+ 'is_assignable': 'true',
+ 'parent': 'computer'}},
+ 'scsi_generic_sg26':
+ {'params': {'capability': 'scsi_generic',
+ 'is_assignable': 'true',
+ 'udev_path': '/dev/sg26',
+ 'parent': 'scsi_6_0_0_14'}},
+ 'scsi_6_0_0_14':
+ {'params': {'product': 'target2-14',
+ 'vendor': 'LIO-ORG',
+ 'parent': 'scsi_target6_0_0',
+ 'driver': 'sd',
+ 'capability': 'scsi',
+ 'is_assignable': 'true',
+ 'udev_path': '/dev/sg26',
+ 'address': {'bus': '0',
+ 'host': '6',
+ 'target': '0',
+ 'lun': '14'}}},
+ 'block_sdr_36001405292bb96f19064f81b884fa63f':
+ {'params': {'capability': 'storage',
+ 'is_assignable': 'true',
+ 'product': 'target1-03',
+ 'vendor': 'LIO-ORG',
+ 'parent': 'scsi_5_0_0_3'}}}
+
+ _schema.schema().verify_retval(
+ vdsmapi.MethodRep('Host', 'hostdevListByCaps'), ret)
+
+ def test_start_spm(self):
+ params = {u'prevLver': u'-1',
+ u'enableScsiFencing': u'false',
+ u'storagepoolID': u'636d9c59-f7ba-4115-87a1-44d6563a9610',
+ u'prevID': -1,
+ u'domVersion': u'3',
+ u'maxHostID': 250}
+
+ _schema.schema().verify_args(
+ vdsmapi.MethodRep('StoragePool', 'spmStart'), params)
+
+ def test_task_status(self):
+ ret = {'code': 0,
+ 'message': 'running job 1 of 1',
+ 'taskState': 'running',
+ 'taskResult': '',
+ 'taskID': '72fdf1ca-8826-4688-9c8c-e175d4253e2a'}
+
+ _schema.schema().verify_retval(
+ vdsmapi.MethodRep('Task', 'getStatus'), ret)
+
+ def test_spm_status(self):
+ ret = {'spmId': 1, 'spmStatus': 'SPM', 'spmLver': 10}
+
+ _schema.schema().verify_retval(
+ vdsmapi.MethodRep('StoragePool', 'getSpmStatus'), ret)
+
+ def test_info_storage(self):
+ ret = {'info':
+ {'name': 'No Description',
+ 'isoprefix': '',
+ 'pool_status': 'connected',
+ 'lver': 10,
+ 'domains': u'0900c0cd-8422-497a-85c5-1bb34b2b6b65:Active,794d',
+ 'master_uuid': '3d4accf7-74af-4ea0-b59b-eb9f10eedb83',
+ 'version': '3',
+ 'spm_id': 1,
+ 'type': 'ISCSI',
+ 'master_ver': 33},
+ 'dominfo': {u'0900c0cd-8422-497a-85c5-1bb34b2b6b65':
+ {'status': u'Active',
+ 'diskfree': '48855252992',
+ 'isoprefix': '',
+ 'alerts': [],
+ 'disktotal': '53284438016',
+ 'version': 3},
+ u'794dc113-315f-43e3-ae47-0b7b1bf56427':
+ {'status': u'Active',
+ 'diskfree': '48855252992',
+ 'isoprefix': '',
+ 'alerts': [],
+ 'disktotal': '53284438016',
+ 'version': 3}}}
+
+ _schema.schema().verify_retval(
+ vdsmapi.MethodRep('StoragePool', 'getInfo'), ret)
+
+ def test_volume_group_info(self):
+ ret = {'state': 'OK',
+ 'vgsize': '53284438016',
+ 'name': 'b0d9c2e8-00e9-4e0e-a5d9-f9e17bb59974',
+ 'vgfree': '48855252992',
+ 'vgUUID': 'aE6hIQ-WY4M-yvgK-rNQi-YN4G-mauM-1xKp56',
+ 'pvlist': [{'vendorID': 'LIO-ORG',
+ 'capacity': '53284438016',
+ 'fwrev': '0000',
+ 'vgUUID': 'aE6hIQ-WY4M-yvgK-rNQi-YN4G-mauM-1xKp56',
+ 'pathlist': [{'connection': '10.35.0.99',
+ 'iqn': 'iqn.2003-01.org.dumbo.target',
+ 'portal': '1',
+ 'port': '3260',
+ 'initiatorname': 'default'}],
+ 'pathstatus': [{'type': 'iSCSI',
+ 'physdev': 'sdbh',
+ 'capacity': '53687091200',
+ 'state': 'active',
+ 'lun': '1'}],
+ 'devtype': 'iSCSI',
+ 'pvUUID': 'mzQhIy-eyno-YUaE-eFod-9JQU-AYeA-xgy0ma',
+ 'serial': 'SLIO-ORG_target3-01_77f3fd04-8038-4383-',
+ 'GUID': '3600140577f3fd048038438393cce45de',
+ 'devcapacity': '53687091200',
+ 'productID': 'target3-01'}],
+ 'type': 3,
+ 'attr': {'allocation': 'n',
+ 'partial': '-',
+ 'exported': '-',
+ 'permission': 'w',
+ 'clustered': '-',
+ 'resizeable': 'z'}}
+
+ _schema.schema().verify_retval(
+ vdsmapi.MethodRep('LVMVolumeGroup', 'getInfo'), ret)
--
To view, visit https://gerrit.ovirt.org/60071
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2420908ebb39136339a5a52daf12f359836c5291
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Piotr Kliczewski <piotr.kliczewski(a)gmail.com>
7 years, 7 months
Change in vdsm[master]: build: Proving that error_code job is useless
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: build: Proving that error_code job is useless
......................................................................
build: Proving that error_code job is useless
Adding new error to vdsm must pass the build. If this patch will fail
the error_codes job, it proves that this job is useless, and it should
be removed.
Checking vdsm error code may be needed as part of engine build, not
vdsm. We do not care if our clients updated their error codes.
Change-Id: Iaf4148cdf286ac694d0aa5fa96e6b302a0fefad9
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M lib/vdsm/exception.py
1 file changed, 5 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/56/61056/1
diff --git a/lib/vdsm/exception.py b/lib/vdsm/exception.py
index 40d13f5..f173ab3 100644
--- a/lib/vdsm/exception.py
+++ b/lib/vdsm/exception.py
@@ -376,3 +376,8 @@
class HookError(GeneralException):
code = 1500
message = "Hook Error"
+
+
+class FooBarError(GeneralException):
+ code = 1501
+ message = "Foo bar error"
--
To view, visit https://gerrit.ovirt.org/61056
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaf4148cdf286ac694d0aa5fa96e6b302a0fefad9
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
7 years, 7 months