Change in vdsm[master]: sourceroute: split gathering of routes and rules off configu...
by osvoboda@redhat.com
Ondřej Svoboda has uploaded a new change for review.
Change subject: sourceroute: split gathering of routes and rules off configure() and remove()
......................................................................
sourceroute: split gathering of routes and rules off configure() and remove()
The code is too complex (for me) to understand. I want to remove the use of
network configurators from the module because they actually call sourceroute
classes' methods only to be called back:
Ifcfg.configureNic, Configurator._addSourceRoute, StaticSourceRoute.configure,
Ifcfg.configureSourceRoute
Ifcfg.removeNic, Ifcfg._ifaceDownAndCleanup, Configurator._removeSourceRoute,
StaticSourceRoute.remove (or DynamicSourceRoute), Ifcfg.removeSourceRoute
Change-Id: I69d8949afbd5b8ba2cf14930533cda99a4580eb0
Signed-off-by: Ondřej Svoboda <osvoboda(a)redhat.com>
---
M vdsm/network/sourceroute.py
1 file changed, 30 insertions(+), 22 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/93/41593/1
diff --git a/vdsm/network/sourceroute.py b/vdsm/network/sourceroute.py
index 5f06de0..d7916ed 100644
--- a/vdsm/network/sourceroute.py
+++ b/vdsm/network/sourceroute.py
@@ -25,11 +25,7 @@
from vdsm import netinfo
from vdsm.constants import P_VDSM_RUN
-from vdsm.ipwrapper import IPRoute2Error
-from vdsm.ipwrapper import Route
-from vdsm.ipwrapper import routeShowTable
-from vdsm.ipwrapper import Rule
-from vdsm.ipwrapper import ruleList
+from vdsm.ipwrapper import IPRoute2Error, Route, routeShowTable, Rule, ruleList
from vdsm.utils import rmFile
@@ -67,23 +63,32 @@
Rule(destination=self._network, table=self._table,
srcDevice=self.device)]
- def configure(self):
+ def _prepare_configuration(self):
logging.info(("Configuring gateway - ip: %s, network: %s, " +
"subnet: %s, gateway: %s, table: %s, device: %s") %
(self._ipaddr, self._network, self._mask, self._gateway,
self._table, self.device))
- routes = self._buildRoutes()
- rules = self._buildRules()
+ self.routes = self._buildRoutes()
+ self.rules = self._buildRules()
+ def configure(self):
+ self._prepare_configuration()
try:
- self._configurator.configureSourceRoute(routes, rules, self.device)
+ self._configurator.configureSourceRoute(self.routes, self.rules,
+ self.device)
except IPRoute2Error as e:
logging.error('ip binary failed during source route configuration'
': %s', e.message)
+ def _prepare_removal(self):
+ self.routes = None
+ self.rules = None
+
def remove(self):
- self._configurator.removeSourceRoute(None, None, self.device)
+ self._prepare_removal()
+ self._configurator.removeSourceRoute(self.routes, self.rules,
+ self.device)
class DynamicSourceRoute(StaticSourceRoute):
@@ -157,20 +162,23 @@
return rules
+ def _prepare_removal(self):
+ self.rules = self._getRules(self.device)
+ if self.rules:
+ self.table = self._getTable(self.rules)
+ if self.table:
+ self.routes = self._getRoutes(self.table)
+
def remove(self):
logging.info("Removing gateway - device: %s", self.device)
-
- rules = self._getRules(self.device)
- if rules:
- table = self._getTable(rules)
- if table:
- try:
- self._configurator.removeSourceRoute(
- self._getRoutes(table), rules,
- self.device)
- except IPRoute2Error as e:
- logging.error('ip binary failed during source route '
- 'removal: %s' % e.message)
+ self._prepare_removal()
+ if self.rules and self.table:
+ try:
+ self._configurator.removeSourceRoute(
+ self.routes, self.rules, self.device)
+ except IPRoute2Error as e:
+ logging.error('ip binary failed during source route '
+ 'removal: %s' % e.message)
@staticmethod
def _isLibvirtInterfaceFallback(device):
--
To view, visit https://gerrit.ovirt.org/41593
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I69d8949afbd5b8ba2cf14930533cda99a4580eb0
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ondřej Svoboda <osvoboda(a)redhat.com>
7 years, 10 months
Change in vdsm[master]: sourceroute: move exception handling to the respective confi...
by osvoboda@redhat.com
Ondřej Svoboda has uploaded a new change for review.
Change subject: sourceroute: move exception handling to the respective configurator
......................................................................
sourceroute: move exception handling to the respective configurator
Change-Id: I579b1789522eaed025d1c059bcf7a900e499ef32
Signed-off-by: Ondřej Svoboda <osvoboda(a)redhat.com>
---
M vdsm/network/configurators/iproute2.py
M vdsm/network/sourceroute.py
2 files changed, 16 insertions(+), 19 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/94/41594/1
diff --git a/vdsm/network/configurators/iproute2.py b/vdsm/network/configurators/iproute2.py
index c260bfe..bec32f7 100644
--- a/vdsm/network/configurators/iproute2.py
+++ b/vdsm/network/configurators/iproute2.py
@@ -201,17 +201,22 @@
@staticmethod
def configureSourceRoute(routes, rules, device):
- for route in routes:
- routeAdd(route)
-
- for rule in rules:
- ruleAdd(rule)
+ try:
+ for route in routes:
+ routeAdd(route)
+ for rule in rules:
+ ruleAdd(rule)
+ except IPRoute2Error as e:
+ logging.error('Source route configuration failed: %s', e.message)
@staticmethod
def removeSourceRoute(routes, rules, device):
# Routes are removed automatically when the link goes down.
- for rule in rules:
- ruleDel(rule)
+ try:
+ for rule in rules:
+ ruleDel(rule)
+ except IPRoute2Error as e:
+ logging.error('Source route removal failed: %s' % e.message)
class ConfigApplier(object):
diff --git a/vdsm/network/sourceroute.py b/vdsm/network/sourceroute.py
index d7916ed..1fb9626 100644
--- a/vdsm/network/sourceroute.py
+++ b/vdsm/network/sourceroute.py
@@ -74,12 +74,8 @@
def configure(self):
self._prepare_configuration()
- try:
- self._configurator.configureSourceRoute(self.routes, self.rules,
- self.device)
- except IPRoute2Error as e:
- logging.error('ip binary failed during source route configuration'
- ': %s', e.message)
+ self._configurator.configureSourceRoute(self.routes, self.rules,
+ self.device)
def _prepare_removal(self):
self.routes = None
@@ -173,12 +169,8 @@
logging.info("Removing gateway - device: %s", self.device)
self._prepare_removal()
if self.rules and self.table:
- try:
- self._configurator.removeSourceRoute(
- self.routes, self.rules, self.device)
- except IPRoute2Error as e:
- logging.error('ip binary failed during source route '
- 'removal: %s' % e.message)
+ self._configurator.removeSourceRoute(self.routes, self.rules,
+ self.device)
@staticmethod
def _isLibvirtInterfaceFallback(device):
--
To view, visit https://gerrit.ovirt.org/41594
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I579b1789522eaed025d1c059bcf7a900e499ef32
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ondřej Svoboda <osvoboda(a)redhat.com>
7 years, 10 months
Change in vdsm[master]: register: handle non uuid machines
by Douglas Schilling Landgraf
Douglas Schilling Landgraf has uploaded a new change for review.
Change subject: register: handle non uuid machines
......................................................................
register: handle non uuid machines
If user machines doesn't provide UUID data this patch
collects a random UUID from system.
Change-Id: I9429e46895a73178cf459d5ced5d39499e993922
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1268854
Signed-off-by: Douglas Schilling Landgraf <dougsland(a)redhat.com>
---
M lib/vdsm/tool/register.py
1 file changed, 11 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/85/47385/1
diff --git a/lib/vdsm/tool/register.py b/lib/vdsm/tool/register.py
index 47c8412..d088bfc 100644
--- a/lib/vdsm/tool/register.py
+++ b/lib/vdsm/tool/register.py
@@ -256,7 +256,17 @@
if self.vdsm_uuid:
self.uuid = self.vdsm_uuid
else:
- self.uuid = getHostUUID(legacy=False)
+ uuid_node = getHostUUID(legacy=False)
+ if uuid_node is None:
+ self.logger.debug("Collecting random UUID from system")
+ random_uuid_path = '/proc/sys/kernel/random/uuid'
+ if os.path.exists(random_uuid_path):
+ with open(random_uuid_path, 'r') as f:
+ self.uuid = f.readline().strip()
+ else:
+ raise RuntimeError("Unable to determine host UUID!")
+ else:
+ self.uuid = uuid_node
self.url_reg += "&uniqueId={u}".format(u=self.uuid)
--
To view, visit https://gerrit.ovirt.org/47385
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9429e46895a73178cf459d5ced5d39499e993922
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Douglas Schilling Landgraf <dougsland(a)redhat.com>
7 years, 10 months
Change in vdsm[master]: vm: do not call before_vm_create in dehibernation
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: vm: do not call before_vm_create in dehibernation
......................................................................
vm: do not call before_vm_create in dehibernation
For reasons unknown, VDSM calls the before_vm_create hook
also in the dehibernation path.
This is wasteful and useless at best, and most likely misleading
and wrong, because VDSM logs the XML it produced, which is *not* what is
gonna be used in the dehibernation path. The hook is fed with
phony data, and the output of the hook is discarded.
This patch dispel the lie and avoid to call the before_vm_create
hook in the dehibernation path.
Change-Id: I4c1377346b1ae63a1feb15e1458b5141c255c849
X-Backport-To: 3.6
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M vdsm/virt/vm.py
1 file changed, 0 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/74/45074/1
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index c54853a..b77b9df 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -1887,8 +1887,6 @@
hooks.before_vm_dehibernate(srcDomXML, self.conf,
{'FROM_SNAPSHOT': str(fromSnapshot)})
- # TODO: this silliness is only to preserve the old behaviour
- hooks.before_vm_start(self._buildDomainXML(), self.conf)
# TODO: this is debug information. For 3.6.x we still need to
# see the XML even with 'info' as default level.
self.log.info(srcDomXML)
--
To view, visit https://gerrit.ovirt.org/45074
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4c1377346b1ae63a1feb15e1458b5141c255c849
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
7 years, 10 months
Change in vdsm[master]: api: allow setLogLevel to tune a specific logger
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: api: allow setLogLevel to tune a specific logger
......................................................................
api: allow setLogLevel to tune a specific logger
the not widely known setLogLevel VDSM verb allows to dinamically tune
the log level of the root logger, until the next restart of VDSM.
This patch extends the API to let the client tune any specific
logger.
Change-Id: I8f40488fac04031552f36b9de026a0062ab81db0
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M vdsm/API.py
M vdsm/rpc/BindingXMLRPC.py
M vdsm/rpc/vdsmapi-schema.json
3 files changed, 12 insertions(+), 6 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/26/38426/1
diff --git a/vdsm/API.py b/vdsm/API.py
index 85478b1..593f336 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -1360,7 +1360,7 @@
return {'status': doneCode, 'info': stats}
- def setLogLevel(self, level):
+ def setLogLevel(self, level, name=None):
"""
Set verbosity level of vdsm's log.
@@ -1382,8 +1382,10 @@
except KeyError:
return errCode['unavail']
else:
- logging.info('Setting loglevel to %s (%d)', level, log_level)
- _set_log_level(logging.getLogger(), log_level)
+ logger = logging.getLogger(name)
+ logging.info('Setting loglevel on %s to %s (%d)',
+ logger.name, level, log_level)
+ _set_log_level(logger, log_level)
return {'status': doneCode}
# VM-related functions
diff --git a/vdsm/rpc/BindingXMLRPC.py b/vdsm/rpc/BindingXMLRPC.py
index b01b661..ea0e0c3 100644
--- a/vdsm/rpc/BindingXMLRPC.py
+++ b/vdsm/rpc/BindingXMLRPC.py
@@ -583,9 +583,9 @@
return api.fenceNode(addr, port, agent, username, password, action,
secure, options, policy)
- def setLogLevel(self, level):
+ def setLogLevel(self, level, name=None):
api = API.Global()
- return api.setLogLevel(level)
+ return api.setLogLevel(level, name)
def setMOMPolicy(self, policy):
api = API.Global()
diff --git a/vdsm/rpc/vdsmapi-schema.json b/vdsm/rpc/vdsmapi-schema.json
index 1d919e8..854e7aa 100644
--- a/vdsm/rpc/vdsmapi-schema.json
+++ b/vdsm/rpc/vdsmapi-schema.json
@@ -4030,10 +4030,14 @@
#
# @level: The new verosity level desired
#
+# @name: #optional If present, change settings only for the logger
+# with this name. Otherwise, change settings for the top-level
+# logger (new in version 4.17.0).
+#
# Since: 4.10.0
##
{'command': {'class': 'Host', 'name': 'setLogLevel'},
- 'data': {'level': 'LoggingLevel'}}
+ 'data': {'level': 'LoggingLevel', '*name': 'str'}}
##
# @Host.setSafeNetworkConfig:
--
To view, visit https://gerrit.ovirt.org/38426
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8f40488fac04031552f36b9de026a0062ab81db0
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
7 years, 10 months
Change in vdsm[master]: API: streamline and make setLogLevel correct
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: API: streamline and make setLogLevel correct
......................................................................
API: streamline and make setLogLevel correct
According to the schema, setLogLevel should accept
a log level string ('DEBUG', 'INFO',...). But the code
actually blindly casted the given value to int(), and this suggests
the code actually expected an integer value.
To make things a bit user friendlier and comformant to schema, change
the argument to actually be a log level in string format.
Along the way, this patch streamlines the implementation of setLogLevel
and makes it simpler.
Change-Id: Iaddbb12d13bdbaa7a02255ab209da11e42d2ea97
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M vdsm/API.py
1 file changed, 21 insertions(+), 6 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/25/38425/1
diff --git a/vdsm/API.py b/vdsm/API.py
index 5cbda50..85478b1 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -1369,13 +1369,22 @@
Doesn't survive a restart
"""
- logging.info('Setting loglevel to %s', level)
- handlers = logging.getLogger().handlers
- [fileHandler] = [h for h in handlers if
- isinstance(h, logging.FileHandler)]
- fileHandler.setLevel(int(level))
+ LEVELS = {
+ 'DEBUG': logging.DEBUG,
+ 'INFO': logging.INFO,
+ 'WARNING': logging.WARNING,
+ 'ERROR': logging.ERROR,
+ 'CRITICAL': logging.CRITICAL
+ }
- return {'status': doneCode}
+ try:
+ log_level = LEVELS[level]
+ except KeyError:
+ return errCode['unavail']
+ else:
+ logging.info('Setting loglevel to %s (%d)', level, log_level)
+ _set_log_level(logging.getLogger(), log_level)
+ return {'status': doneCode}
# VM-related functions
def getVMList(self, fullStatus=False, vmList=()):
@@ -1772,3 +1781,9 @@
logging.warn("options %s is deprecated. Use %s instead" %
(k, _translationMap[k]))
options[_translationMap[k]] = options.pop(k)
+
+
+def _set_log_level(logger, log_level):
+ for handler in logger.handlers:
+ if isinstance(handler, logging.FileHandler):
+ handler.setLevel(log_level)
--
To view, visit https://gerrit.ovirt.org/38425
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaddbb12d13bdbaa7a02255ab209da11e42d2ea97
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
7 years, 10 months
Change in vdsm[master]: virt: Correct VM state before vm.cont() in _recover()
by smelamud@redhat.com
Shmuel Leib Melamud has uploaded a new change for review.
Change subject: virt: Correct VM state before vm.cont() in _recover()
......................................................................
virt: Correct VM state before vm.cont() in _recover()
In SourceThread._recover(), if error occured while hibernating a VM, set
VM status to PAUSED before calling vm.cont(). Otherwise, vm.cont() will
fail to run in SAVING_STATE state and the VM will be left paused.
Change-Id: I5b1c7b4eecacf87ece48dc563fd2da294af0510b
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1238536
Signed-off-by: Shmuel Melamud <smelamud(a)redhat.com>
---
M vdsm/virt/migration.py
1 file changed, 1 insertion(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/27/47527/1
diff --git a/vdsm/virt/migration.py b/vdsm/virt/migration.py
index 32caccb..f950a6f 100644
--- a/vdsm/virt/migration.py
+++ b/vdsm/virt/migration.py
@@ -213,6 +213,7 @@
self.log.exception("Failed to destroy remote VM")
# if the guest was stopped before migration, we need to cont it
if self.hibernating:
+ self._vm.lastStatus = vmstatus.PAUSED
self._vm.cont()
# either way, migration has finished
self._vm.lastStatus = vmstatus.UP
--
To view, visit https://gerrit.ovirt.org/47527
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5b1c7b4eecacf87ece48dc563fd2da294af0510b
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Shmuel Leib Melamud <smelamud(a)redhat.com>
7 years, 11 months
Change in vdsm[master]: v2v: add fake virt-v2v process for testing without virt-v2v
by shavivi@redhat.com
Shahar Havivi has uploaded a new change for review.
Change subject: v2v: add fake virt-v2v process for testing without virt-v2v
......................................................................
v2v: add fake virt-v2v process for testing without virt-v2v
Change-Id: If062a1136921af19a2ffcb4d147611bbc9cf5464
Signed-off-by: Shahar Havivi <shaharh(a)redhat.com>
---
M tests/Makefile.am
A tests/fakeVirtV2V.py
M tests/v2vTests.py
3 files changed, 49 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/38/47738/1
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1168862..185c9d7 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -196,6 +196,7 @@
$(test_modules) \
apiData.py \
hookValidation.py \
+ fakeVirtV2V.py \
monkeypatch.py \
nettestlib.py \
storagefakelib.py \
diff --git a/tests/fakeVirtV2V.py b/tests/fakeVirtV2V.py
new file mode 100755
index 0000000..72c78c8
--- /dev/null
+++ b/tests/fakeVirtV2V.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+
+import sys
+
+if len(sys.argv) != 2:
+ print ('usage: %s <target dir>\n' % sys.argv[0])
+ sys.exit(1)
+
+
+target_dir = sys.argv[1]
+
+
+def write_progress():
+ for i in range(101):
+ print(" (%s/100%%)\r" % str(i))
+
+
+print('[ 0.0] Opening the source -i libvirt\n')
+print('[ 1.0] Creating an overlay to protect\n')
+print('[ 88.0] Copying disk 1/2 to %s/4d8daea0-bf69-4984-9775-c0e826325669'
+ '/images/1c1e7572-a23a-4b19-89b9-09564b5c575e\n' % target_dir)
+write_progress()
+print('[ 88.0] Copying disk 2/2 to %s/4d8daea0-bf69-4984-9775-c0e826325669'
+ '/images/1c1e7572-a23a-4b19-89b9-09564b5c575e\n' % target_dir)
+write_progress()
+print('[ 256.0] Creating output metadata')
+print('[ 256.0] Finishing off')
diff --git a/tests/v2vTests.py b/tests/v2vTests.py
index 3264d26..b3dd869 100644
--- a/tests/v2vTests.py
+++ b/tests/v2vTests.py
@@ -20,6 +20,7 @@
from StringIO import StringIO
import libvirt
+import os
import v2v
from vdsm import libvirtconnection
@@ -237,3 +238,23 @@
self.assertEquals(network['type'], 'bridge')
self.assertEquals(network['macAddr'], '00:0c:29:c6:a6:11')
self.assertEquals(network['bridge'], 'VM Network')
+
+ def prepare_volumes(self):
+ return 0
+
+ def create_command(self):
+ return [os.path.join(os.path.abspath('.'), 'fakeVirtV2V.py'),
+ '/tmp/images']
+
+ def execution_environments(self):
+ return {}
+
+ @MonkeyPatch(v2v.ImportVm, '_prepare_volumes', prepare_volumes)
+ @MonkeyPatch(v2v.ImportVm, '_from_libvirt_command', create_command)
+ @MonkeyPatch(v2v.ImportVm, '_execution_environments',
+ execution_environments)
+ def testVirtV2V(self):
+ ivm = v2v.ImportVm.from_libvirt(None, None, None, None,
+ 'e3e52628-5c12-414d-9283-28914a3a7e7e',
+ None)
+ ivm._import()
--
To view, visit https://gerrit.ovirt.org/47738
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If062a1136921af19a2ffcb4d147611bbc9cf5464
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Shahar Havivi <shavivi(a)redhat.com>
8 years, 6 months
Change in vdsm[master]: storage: Use new concurrent.thread() utility
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: storage: Use new concurrent.thread() utility
......................................................................
storage: Use new concurrent.thread() utility
This patch updates the storage subsystem to use the new utility.
Behavior changes:
- fcscan.Scan threads are protected from silent failures.
- misc.Event notification threads are protected from silent failures,
and are daemonic.
- misc.itmap threads are protected from silent failures and are
daemonic.
- resourceManager.ResourceRef __del__ threads are protected from
silent failures and are daemonic.
- sd.StorageDomain __del__ threads are protected from silent failures
and are daemonic.
- sp.StoragePool upgrade threads are protected from silent failures
and are daemonic.
- storageServer.ConnectionMonitor thread is protected now from silent
failures.
- sync.AsyncCallStub call threads are protected from silent failures and
are daemonic (they were explicitily non-daemonic before).
- task.Task __del__ threads are protected from silent failures and
are daemonic.
- threadPool.WorkerThread threads are protected from silent failures
Notes:
- storage_mailbox.HSM_MailMonitor inherits now from object and keeps a
thread instance.
- threadPool.WorkerThread inherits now from object and keeps an thread
instance.
Change-Id: I83b09cac366417cd22d5d4976d334cf9632a53f5
Relates-To: https://bugzilla.redhat.com/1141422
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M vdsm/storage/fc-scan
M vdsm/storage/hsm.py
M vdsm/storage/misc.py
M vdsm/storage/monitor.py
M vdsm/storage/resourceManager.py
M vdsm/storage/sd.py
M vdsm/storage/sp.py
M vdsm/storage/storageServer.py
M vdsm/storage/storage_mailbox.py
M vdsm/storage/sync.py
M vdsm/storage/task.py
M vdsm/storage/threadPool.py
12 files changed, 50 insertions(+), 48 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/52/45552/1
diff --git a/vdsm/storage/fc-scan b/vdsm/storage/fc-scan
index f21f93c..119a735 100755
--- a/vdsm/storage/fc-scan
+++ b/vdsm/storage/fc-scan
@@ -39,8 +39,8 @@
import logging
import os
import sys
-import threading
+from vdsm import concurrent
from vdsm import utils
log = logging.getLogger("fc-scan")
@@ -54,8 +54,7 @@
self.thread = None
def start(self):
- self.thread = threading.Thread(target=self.run)
- self.thread.daemon = True
+ self.thread = concurrent.thread(self.run, logger=log.name)
self.thread.start()
def wait(self):
diff --git a/vdsm/storage/hsm.py b/vdsm/storage/hsm.py
index 0806abb..0f8f5fd 100644
--- a/vdsm/storage/hsm.py
+++ b/vdsm/storage/hsm.py
@@ -23,7 +23,6 @@
"""
import os
-import threading
import logging
import glob
from fnmatch import fnmatch
@@ -38,6 +37,7 @@
import numbers
import stat
+from vdsm import concurrent
from vdsm.config import config
import sp
from spbackends import MAX_POOL_DESCRIPTION_SIZE, MAX_DOMAINS
@@ -365,16 +365,15 @@
except Exception:
self.log.warn("Failed to clean Storage Repository.", exc_info=True)
- @utils.traceback(on=self.log.name)
def storageRefresh():
sdCache.refreshStorage()
lvm.bootstrap(refreshlvs=blockSD.SPECIAL_LVS)
self._ready = True
self.log.debug("HSM is ready")
- storageRefreshThread = threading.Thread(target=storageRefresh,
- name="storageRefresh")
- storageRefreshThread.daemon = True
+ storageRefreshThread = concurrent.thread(storageRefresh,
+ name="storageRefresh",
+ logger=self.log.name)
storageRefreshThread.start()
monitorInterval = config.getint('irs', 'sd_health_check_delay')
diff --git a/vdsm/storage/misc.py b/vdsm/storage/misc.py
index b14fd26..bf75ba9 100644
--- a/vdsm/storage/misc.py
+++ b/vdsm/storage/misc.py
@@ -47,6 +47,7 @@
import weakref
import inspect
+from vdsm import concurrent
from vdsm import constants
from vdsm import utils
import storage_exception as se
@@ -788,8 +789,8 @@
if self._sync:
func(*args, **kwargs)
else:
- threading.Thread(target=func, args=args,
- kwargs=kwargs).start()
+ concurrent.thread(func, args=args,
+ kwargs=kwargs).start()
except:
self._log.warn("Could not run registered method because "
"of an exception", exc_info=True)
@@ -798,8 +799,7 @@
def emit(self, *args, **kwargs):
if len(self._registrar) > 0:
- threading.Thread(target=self._emit, args=args,
- kwargs=kwargs).start()
+ concurrent.thread(self._emit, args=args, kwargs=kwargs).start()
class OperationMutex(object):
@@ -921,7 +921,7 @@
maxthreads += 1
threadsCount -= 1
- t = threading.Thread(target=wrapper, args=(arg,))
+ t = concurrent.thread(wrapper, args=(arg,))
t.start()
threadsCount += 1
maxthreads -= 1
diff --git a/vdsm/storage/monitor.py b/vdsm/storage/monitor.py
index 196fc10..80f3373 100644
--- a/vdsm/storage/monitor.py
+++ b/vdsm/storage/monitor.py
@@ -23,6 +23,7 @@
import time
import weakref
+from vdsm import concurrent
from vdsm import utils
from vdsm.config import config
@@ -163,8 +164,7 @@
log = logging.getLogger('Storage.Monitor')
def __init__(self, domainMonitor, sdUUID, hostId, interval):
- self.thread = threading.Thread(target=self._run)
- self.thread.setDaemon(True)
+ self.thread = concurrent.thread(self._run, logger=self.log.name)
self.domainMonitor = domainMonitor
self.stopEvent = threading.Event()
self.domain = None
@@ -200,7 +200,6 @@
""" Accessed by methods decorated with @util.cancelpoint """
return self.stopEvent.is_set()
- @utils.traceback(on=log.name)
def _run(self):
self.log.debug("Domain monitor for %s started", self.sdUUID)
try:
diff --git a/vdsm/storage/resourceManager.py b/vdsm/storage/resourceManager.py
index b1b0dc7..06228e2 100644
--- a/vdsm/storage/resourceManager.py
+++ b/vdsm/storage/resourceManager.py
@@ -29,6 +29,7 @@
import storage_exception as se
import misc
from logUtils import SimpleLogAdapter
+from vdsm import concurrent
from vdsm import utils
@@ -338,8 +339,8 @@
# deadlock. This is why I need to use a timer. It will defer
# the operation and use a different context.
ResourceManager.getInstance().releaseResource(namespace, name)
- threading.Thread(target=release, args=(self._log, self.namespace,
- self.name)).start()
+ concurrent.thread(release, args=(self._log, self.namespace,
+ self.name)).start()
self._isValid = False
def __repr__(self):
diff --git a/vdsm/storage/sd.py b/vdsm/storage/sd.py
index d4e2b5a..da0f7ae 100644
--- a/vdsm/storage/sd.py
+++ b/vdsm/storage/sd.py
@@ -31,6 +31,7 @@
import resourceFactories
from resourceFactories import IMAGE_NAMESPACE, VOLUME_NAMESPACE
import resourceManager as rm
+from vdsm import concurrent
from vdsm import constants
import clusterlock
import outOfProcess as oop
@@ -400,7 +401,7 @@
def __del__(self):
if self.stat:
- threading.Thread(target=self.stat.stop).start()
+ concurrent.thread(self.stat.stop).start()
@property
def sdUUID(self):
diff --git a/vdsm/storage/sp.py b/vdsm/storage/sp.py
index 4a8b67c..087d4eb 100644
--- a/vdsm/storage/sp.py
+++ b/vdsm/storage/sp.py
@@ -31,6 +31,7 @@
from imageRepository.formatConverter import DefaultFormatConverter
+from vdsm import concurrent
from vdsm import constants, utils
import storage_mailbox
import blockSD
@@ -441,9 +442,10 @@
self._upgradeCallback)
self.log.debug("Running initial domain upgrade threads")
for sdUUID in self._domainsToUpgrade:
- threading.Thread(target=self._upgradeCallback,
- args=(sdUUID, True),
- kwargs={"__securityOverride": True}).start()
+ concurrent.thread(self._upgradeCallback,
+ args=(sdUUID, True),
+ kwargs={"__securityOverride": True},
+ logger=self.log.name).start()
@unsecured
def __createMailboxMonitor(self):
diff --git a/vdsm/storage/storageServer.py b/vdsm/storage/storageServer.py
index 6636bd8..d436d7f 100644
--- a/vdsm/storage/storageServer.py
+++ b/vdsm/storage/storageServer.py
@@ -21,7 +21,7 @@
import logging
from os.path import normpath, basename, splitext
import os
-from threading import RLock, Lock, Event, Thread
+from threading import RLock, Lock, Event
import socket
import glob
from collections import namedtuple
@@ -32,6 +32,7 @@
from vdsm.compat import pickle
from vdsm.config import config
+from vdsm import concurrent
from vdsm import supervdsm
from vdsm import udevadm
@@ -777,8 +778,7 @@
self._conDict[alias] = ConnectionFactory.createConnection(conInfo)
def startMonitoring(self):
- t = Thread(target=self._monitorConnections)
- t.setDaemon(True)
+ t = concurrent.thread(self._monitorConnections, logger=self._log.name)
self._stopEvent.clear()
t.start()
diff --git a/vdsm/storage/storage_mailbox.py b/vdsm/storage/storage_mailbox.py
index e2a6708..b30fbab 100644
--- a/vdsm/storage/storage_mailbox.py
+++ b/vdsm/storage/storage_mailbox.py
@@ -34,8 +34,8 @@
import task
from threadPool import ThreadPool
from storage_exception import InvalidParameterException
+from vdsm import concurrent
from vdsm import constants
-from vdsm import utils
__author__ = "ayalb"
__date__ = "$Mar 9, 2009 5:25:07 PM$"
@@ -228,7 +228,7 @@
"available to flush")
-class HSM_MailMonitor(threading.Thread):
+class HSM_MailMonitor(object):
log = logging.getLogger('Storage.MailBox.HsmMailMonitor')
def __init__(self, inbox, outbox, hostID, queue, monitorInterval):
@@ -267,10 +267,9 @@
self._initMailbox() # Read initial mailbox state
self._msgCounter = 0
self._sendMail() # Clear outgoing mailbox
- threading.Thread.__init__(self)
- self.daemon = True
- self.name = "mailbox.HSMMonitor"
- self.start()
+ self._thread = concurrent.thread(self.run, name="mailbox.HSMMonitor",
+ logger=self.log.name)
+ self._thread.start()
def _initMailbox(self):
# Sync initial incoming mail state with storage view
@@ -426,8 +425,6 @@
MESSAGES_PER_MAILBOX,
repr(self._outgoingMail[start:end])))
- @utils.traceback(on=log.name,
- msg="Unhandled exception in HSM_MailMonitor thread")
def run(self):
try:
failures = 0
@@ -581,9 +578,8 @@
self.log.warning("SPM_MailMonitor couldn't clear outgoing mail, "
"dd failed")
- t = threading.Thread(target=self.run)
- t.daemon = True
- t.name = "mailbox.SPMMonitor"
+ t = concurrent.thread(self.run, name="mailbox.SPMMonitor",
+ logger=self.log.name)
t.start()
self.log.debug('SPM_MailMonitor created for pool %s' % self._poolID)
@@ -782,8 +778,6 @@
finally:
self._outLock.release()
- @utils.traceback(on=log.name,
- msg="Unhandled exception in SPM_MailMonitor thread")
def run(self):
try:
while not self._stop:
diff --git a/vdsm/storage/sync.py b/vdsm/storage/sync.py
index 832c85d..8a44497 100644
--- a/vdsm/storage/sync.py
+++ b/vdsm/storage/sync.py
@@ -1,5 +1,6 @@
-from threading import Thread, Event
+from threading import Event
from functools import wraps
+from vdsm import concurrent
def AsyncCallStub(result):
@@ -42,8 +43,7 @@
self._event.set()
def _call(self):
- t = Thread(target=self._wrapper)
- t.setDaemon(False)
+ t = concurrent.thread(self._wrapper)
t.start()
diff --git a/vdsm/storage/task.py b/vdsm/storage/task.py
index bde3421..c558e0e 100644
--- a/vdsm/storage/task.py
+++ b/vdsm/storage/task.py
@@ -58,6 +58,7 @@
import resourceManager
from threadLocal import vars
from weakref import proxy
+from vdsm import concurrent
from vdsm.config import config
import outOfProcess as oop
from logUtils import SimpleLogAdapter
@@ -513,8 +514,8 @@
if (self.cleanPolicy == TaskCleanType.auto and
self.store is not None):
taskDir = os.path.join(self.store, self.id)
- threading.Thread(target=finalize,
- args=(self.log, self.resOwner, taskDir)).start()
+ concurrent.thread(finalize,
+ args=(self.log, self.resOwner, taskDir)).start()
def _done(self):
self.resOwner.releaseAll()
diff --git a/vdsm/storage/threadPool.py b/vdsm/storage/threadPool.py
index 262012a..594a6b9 100644
--- a/vdsm/storage/threadPool.py
+++ b/vdsm/storage/threadPool.py
@@ -11,6 +11,7 @@
from time import sleep
from Queue import Queue, Empty
import logging
+from vdsm import concurrent
class ThreadPool:
@@ -165,7 +166,7 @@
self.__resizeLock.release()
-class WorkerThread(threading.Thread):
+class WorkerThread(object):
""" Pooled thread class. """
@@ -174,10 +175,15 @@
def __init__(self, pool):
""" Initialize the thread and remember the pool. """
- threading.Thread.__init__(self)
+ self._thread = concurrent.thread(self.run)
self.__pool = pool
self.__isDying = False
- self.daemon = True
+
+ def start(self):
+ self._thread.start()
+
+ def join(self):
+ self._thread.join()
def _processNextTask(self):
id, cmd, args, callback = self.__pool.getNextTask()
@@ -189,14 +195,14 @@
self.__pool.__tasks.put((id, cmd, args, callback))
elif callback is None:
self.__pool.setRunningTask(True)
- self.setName(id)
+ self._thread.name = id
self.log.debug("Task: %s running: %s with: %s" %
(id, repr(cmd), repr(args)))
cmd(args)
self.__pool.setRunningTask(False)
else:
self.__pool.setRunningTask(True)
- self.setName(id)
+ self._thread.name = id
callback(cmd(args))
self.__pool.setRunningTask(False)
except Exception:
--
To view, visit https://gerrit.ovirt.org/45552
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I83b09cac366417cd22d5d4976d334cf9632a53f5
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
8 years, 6 months
Change in vdsm[master]: virt: Use new concurrent.thread() utility
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: virt: Use new concurrent.thread() utility
......................................................................
virt: Use new concurrent.thread() utility
This patch updates virt subsystem to use the new utility.
Behavior changes:
- vm.Vm creation threads is protected from silent failures
This patch does not modify some threads inheriting from threading.Thread
instead of having a threading.Thread instance (migration.py, vm.py).
Change-Id: Ibc0c22fee4b2fbebaaedeaadc62418f7905037bd
Relates-To: https://bugzilla.redhat.com/1141422
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M vdsm/v2v.py
M vdsm/virt/vm.py
2 files changed, 5 insertions(+), 5 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/55/45555/1
diff --git a/vdsm/v2v.py b/vdsm/v2v.py
index cdd831b..437fa86 100644
--- a/vdsm/v2v.py
+++ b/vdsm/v2v.py
@@ -36,11 +36,12 @@
import libvirt
+from vdsm import concurrent
from vdsm.constants import P_VDSM_RUN
from vdsm.define import errCode, doneCode
from vdsm import libvirtconnection, response
from vdsm.infra import zombiereaper
-from vdsm.utils import traceback, CommandPath, execCmd, NICENESS, IOCLASS
+from vdsm.utils import CommandPath, execCmd, NICENESS, IOCLASS
import caps
@@ -362,8 +363,7 @@
return obj
def start(self):
- t = threading.Thread(target=self._run_command)
- t.daemon = True
+ t = concurrent.thread(self._run_command)
t.start()
@property
@@ -393,7 +393,6 @@
with password_file(self._id, self._passwd_file, self._password):
self._run()
- @traceback(msg="Error importing vm")
def _run(self):
try:
self._import()
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 90e6652..987313c 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -34,6 +34,7 @@
import libvirt
# vdsm imports
+from vdsm import concurrent
from vdsm import constants
from vdsm import libvirtconnection
from vdsm import netinfo
@@ -265,7 +266,7 @@
self._confLock = threading.Lock()
self._jobsLock = threading.Lock()
self._statusLock = threading.Lock()
- self._creationThread = threading.Thread(target=self._startUnderlyingVm)
+ self._creationThread = concurrent.thread(self._startUnderlyingVm)
if 'migrationDest' in self.conf:
self._lastStatus = vmstatus.MIGRATION_DESTINATION
elif 'restoreState' in self.conf:
--
To view, visit https://gerrit.ovirt.org/45555
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibc0c22fee4b2fbebaaedeaadc62418f7905037bd
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
8 years, 6 months