Bug 726643

Summary: host installation failed - vds_bootstrap imports utils from yum [for RHEL 5.8 / VDSM 2.2.x]
Product: Red Hat Enterprise Linux 5 Reporter: Pavel Stehlik <pstehlik>
Component: vdsm22Assignee: Federico Simoncelli <fsimonce>
Status: CLOSED ERRATA QA Contact: Pavel Stehlik <pstehlik>
Severity: urgent Docs Contact:
Priority: urgent    
Version: 5.7CC: abaron, acathrow, andriusb, bazulay, cpelland, danken, dpaikov, fsimonce, iheim, kgrainge, rdassen, sgordon, ykaul
Target Milestone: rcKeywords: Regression, Reopened, ZStream
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: rhev-m-2.2.9.1 Doc Type: Bug Fix
Doc Text:
Attaching a Red Hat Enterprise Linux 5.7 host to a Red Hat Enterprise Virtualization Manager failed because when the bootstrap process imported the utilities, installing utils from yum overwrote the VDSM directory from the current Python path. The VDSM directory is now added to the current Python path so you can attach the 5.7 host successfully.
Story Points: ---
Clone Of:
: 726941 (view as bug list) Environment:
Last Closed: 2012-02-21 04:53:02 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 726937, 726941, 729324    

Comment 2 Miroslav Suchý 2011-07-29 12:11:41 UTC
I would say that bug 726644 is not in fault. You just import it and you hope it will work. But..:

If you do:
  import utils
and utils already exist in cache then it is used. Today it is rhnplugin, but tomorrow it will be somebody else. And it will not help you to prepend path to sys.path, since that package is already in cache. See:
http://docs.python.org/reference/simple_stmts.html#import

Correct way to avoid is to not install packages to
 /usr/share/vdsm/
but to
 %{python_sitelib}/vdsm
where
 %if 0%{?rhel} && 0%{?rhel} < 6
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
%endif

Then you can do:
 import vdsm.utils
and you will have no conflict now nor in future.

Comment 3 Federico Simoncelli 2011-07-29 12:52:49 UTC
I agree on the fact that we should move to %{python_sitelib}/vdsm.

Nevertheless we won't face this problem anyway because the imported modules never change sys.path.

Also your plugin is not immune by this very same problem:

# mkdir rhnplugin-test && cd rhnplugin-test
# touch output.py
# python
>>> import os, sys, yum
>>> sys.path.append(os.getcwd())
>>> my = yum.YumBase()
>>> cu = my.pkgSack.searchNevra(name='coreutils')
Plugin "rhnplugin" can't be imported
Loaded plugins: product-id

Comment 5 Federico Simoncelli 2011-08-01 08:32:08 UTC
BZ#726643 Force VDSM_DIR in sys.path
Change-Id: I9d951b1263bac52c350fe02012a5cfeeef48ba70

http://gerrit.usersys.redhat.com/766

Comment 7 Daniel Paikov 2011-08-10 13:32:40 UTC
Checked on sm109.

Comment 8 Kate Grainger 2011-08-24 07:36:35 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Attaching a Red Hat Enterprise Linux 5.7 host to a Red Hat Enterprise Virtualization manager failed because when the bootstrap process imported the utilities, installing utils from yum overwrote the VDSM directory from the current Python path. The VDSM directory is now added to the current Python path so you can attach the 5.7 host successfully.

Comment 9 Stephen Gordon 2012-02-13 16:19:07 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1 +1 @@
-Attaching a Red Hat Enterprise Linux 5.7 host to a Red Hat Enterprise Virtualization manager failed because when the bootstrap process imported the utilities, installing utils from yum overwrote the VDSM directory from the current Python path. The VDSM directory is now added to the current Python path so you can attach the 5.7 host successfully.+Attaching a Red Hat Enterprise Linux 5.7 host to a Red Hat Enterprise Virtualization Manager failed because when the bootstrap process imported the utilities, installing utils from yum overwrote the VDSM directory from the current Python path. The VDSM directory is now added to the current Python path so you can attach the 5.7 host successfully.

Comment 10 errata-xmlrpc 2012-02-21 04:53:02 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2012-0169.html