You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ambari.apache.org by Andrew Onischuk <ao...@hortonworks.com> on 2015/08/28 11:25:47 UTC

Review Request 37882: Python Wrapper Can Choose Two Different Python Versions

-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/37882/
-----------------------------------------------------------

Review request for Ambari and Vitalyi Brodetskyi.


Bugs: AMBARI-12912
    https://issues.apache.org/jira/browse/AMBARI-12912


Repository: ambari


Description
-------

Environments that have 2 different versions of Python cause problems when
running agent code in memory. This was encountered on an Ambari 1.6 upgrade to
2.1 where Python 2.6 had all of the site-packages, but python2.7 was being
chosen by the agent.

The `ambari-python-wrap` script is the problem. Consider the code:

    
    
    
    export PYTHONPATH=/usr/lib/python2.6/site-packages:/usr/lib/python2.6/site-packages/ambari_commons:$PYTHONPATH
    
    # reset settings
    unset PYTHON
    
    # checking for preferable python versions
    if [ -a /usr/bin/python2.7 ] && [ -z "$PYTHON" ]; then
      PYTHON=/usr/bin/python2.7
    fi
    
    if [ -a /usr/bin/python2.6 ] && [ -z "$PYTHON" ]; then
      PYTHON=/usr/bin/python2.6
    fi
    

This is hardcoding the `PYTHONPATH` to use `site-packages` from `python2.6`.
But then, it choose the Python 2.7 executor as the wrapper. This means that
the agents will be running as Python 2.7 and executing scripts with a Python
2.6 site-package.

The observed problem was that the "rpm" and "yum" packages could not be loaded
by agent code on an INSTALL command since these packages were part of the 2.6
site-packages and not 2.7 site-packages.


Diffs
-----

  ambari-common/src/main/unix/ambari-python-wrap b9cf3b6 

Diff: https://reviews.apache.org/r/37882/diff/


Testing
-------

mvn clean test


Thanks,

Andrew Onischuk


Re: Review Request 37882: Python Wrapper Can Choose Two Different Python Versions

Posted by Vitalyi Brodetskyi <vb...@hortonworks.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/37882/#review96847
-----------------------------------------------------------

Ship it!


Ship It!

- Vitalyi Brodetskyi


On Сер. 28, 2015, 9:25 до полудня, Andrew Onischuk wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/37882/
> -----------------------------------------------------------
> 
> (Updated Сер. 28, 2015, 9:25 до полудня)
> 
> 
> Review request for Ambari and Vitalyi Brodetskyi.
> 
> 
> Bugs: AMBARI-12912
>     https://issues.apache.org/jira/browse/AMBARI-12912
> 
> 
> Repository: ambari
> 
> 
> Description
> -------
> 
> Environments that have 2 different versions of Python cause problems when
> running agent code in memory. This was encountered on an Ambari 1.6 upgrade to
> 2.1 where Python 2.6 had all of the site-packages, but python2.7 was being
> chosen by the agent.
> 
> The `ambari-python-wrap` script is the problem. Consider the code:
> 
>     
>     
>     
>     export PYTHONPATH=/usr/lib/python2.6/site-packages:/usr/lib/python2.6/site-packages/ambari_commons:$PYTHONPATH
>     
>     # reset settings
>     unset PYTHON
>     
>     # checking for preferable python versions
>     if [ -a /usr/bin/python2.7 ] && [ -z "$PYTHON" ]; then
>       PYTHON=/usr/bin/python2.7
>     fi
>     
>     if [ -a /usr/bin/python2.6 ] && [ -z "$PYTHON" ]; then
>       PYTHON=/usr/bin/python2.6
>     fi
>     
> 
> This is hardcoding the `PYTHONPATH` to use `site-packages` from `python2.6`.
> But then, it choose the Python 2.7 executor as the wrapper. This means that
> the agents will be running as Python 2.7 and executing scripts with a Python
> 2.6 site-package.
> 
> The observed problem was that the "rpm" and "yum" packages could not be loaded
> by agent code on an INSTALL command since these packages were part of the 2.6
> site-packages and not 2.7 site-packages.
> 
> 
> Diffs
> -----
> 
>   ambari-common/src/main/unix/ambari-python-wrap b9cf3b6 
> 
> Diff: https://reviews.apache.org/r/37882/diff/
> 
> 
> Testing
> -------
> 
> mvn clean test
> 
> 
> Thanks,
> 
> Andrew Onischuk
> 
>