Change in vdsm[master]: vdsm-tool: handle error during module loading

ybronhei at redhat.com ybronhei at redhat.com
Mon Jan 20 15:36:28 UTC 2014


Yaniv Bronhaim has uploaded a new change for review.

Change subject: vdsm-tool: handle error during module loading
......................................................................

vdsm-tool: handle error during module loading

While vdsm-tool initiates it loads all python modules under tool folder.
If one of them throws exception vdsm-tool fails to run. This patch
handles such exception and reports it to syslog.

Change-Id: I023ad390723617d10664f9bf5b8d1460131efef2
Signed-off-by: Yaniv Bronhaim <ybronhei at redhat.com>
---
M vdsm-tool/vdsm-tool
1 file changed, 10 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/56/23456/1

diff --git a/vdsm-tool/vdsm-tool b/vdsm-tool/vdsm-tool
index c85b026..02d0901 100755
--- a/vdsm-tool/vdsm-tool
+++ b/vdsm-tool/vdsm-tool
@@ -23,6 +23,8 @@
 import imp
 import getopt
 import textwrap
+import syslog
+import traceback
 
 import vdsm.tool
 
@@ -72,8 +74,14 @@
             continue
 
         mod_fobj, mod_absp, mod_desc = imp.find_module(mod_name, [mod_path])
-        module = imp.load_module(package_name + '.' + mod_name, mod_fobj,
-                                 mod_absp, mod_desc)
+        try:
+            module = imp.load_module(package_name + '.' + mod_name, mod_fobj,
+                                     mod_absp, mod_desc)
+        except (TypeError, IndexError, ValueError, AssertionError):
+            # py module is corrupted by wrong imports. move on and ignore it
+            syslog.syslog("module %s could not load to vdsm-tool: %s" %
+                          (mod_name, traceback.format_exc()))
+            continue
 
         mod_cmds = []
 


-- 
To view, visit http://gerrit.ovirt.org/23456
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I023ad390723617d10664f9bf5b8d1460131efef2
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yaniv Bronhaim <ybronhei at redhat.com>


More information about the vdsm-patches mailing list