Nir Soffer has posted comments on this change.
Change subject: Hack to fix vdsm-tool import issues during upgrade
......................................................................
Patch Set 7:
(3 comments)
https://gerrit.ovirt.org/#/c/39408/7/vdsm-tool/vdsm-tool
File vdsm-tool/vdsm-tool:
Line 35: # all tool's verbs are loaded from the old vdsm code.
Line 36: ########################################################################
Line 37: import imp
Line 38: vdsm_libdir = [os.path.join(os.path.dirname(os.__file__).
Line 39: replace('lib64', 'lib'), 'site-packages')
+ '/vdsm']
Add 'vdsm' at the end:
os.path.join(..., 'site-packages', 'vdsm')
Line 40: tool = imp.load_module('vdsm.tool',
Line 41: *imp.find_module('tool', vdsm_libdir))
Line 42: ########################################################################
Line 43:
Line 37: import imp
Line 38: vdsm_libdir = [os.path.join(os.path.dirname(os.__file__).
Line 39: replace('lib64', 'lib'), 'site-packages')
+ '/vdsm']
Line 40: tool = imp.load_module('vdsm.tool',
Line 41: *imp.find_module('tool', vdsm_libdir))
This does not match the behavior of regular imports - when you do
"import vdsm.tool" - the system will import both vdsm and tool, and set
vdsm.tool. This is the reason I suggested to import both vdsm and tool.
Please check what happens when modules under vdsm/tool/ are importing
stuff from vdsm - for example:
from vdsm import utils
It is possible that the modules will get old utils from /usr/lib64/ and we
will have a horrible mess.
Hopefully, if you did import vdsm from /usr/lib, when other modules import
stuff from vdsm they will use vdsm.__file__ to locate the other modules,
and will get them also from /usr/lib.
To debug this, run the tool with python -v, and check that all the imports are
expected.
Line 42: ########################################################################
Line 43:
Line 44: tool_modules = []
Line 45: tool_command = {}
Line 79: """
Line 80: global tool_modules, tool_command
Line 81:
Line 82: mod_path = os.path.dirname(tool.__file__)
Line 83: package_name = tool.__name__
Importing vdsm.tool will avoid these changes and will keep this patch smaller.
Line 84:
Line 85: for mod_name in _listPathModules(mod_path):
Line 86: if mod_name.startswith("_"):
Line 87: continue
--
To view, visit
https://gerrit.ovirt.org/39408
To unsubscribe, visit
https://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: Idf3669b06b308399cb78866d72b592ac2d8b1732
Gerrit-PatchSet: 7
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Yaniv Bronhaim <ybronhei(a)redhat.com>
Gerrit-Reviewer: Federico Simoncelli <fsimonce(a)redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer(a)redhat.com>
Gerrit-Reviewer: Oved Ourfali <oourfali(a)redhat.com>
Gerrit-Reviewer: Yaniv Bronhaim <ybronhei(a)redhat.com>
Gerrit-Reviewer: automation(a)ovirt.org
Gerrit-HasComments: Yes