[openstack-dev] [cinder] Port Cinder to Python 3

Victor Stinner vstinner at redhat.com
Tue May 26 09:44:35 UTC 2015


(Oops, I sent a draft by mistake, sorry about that.)

Hi,

There is an ongoing effort to port OpenStack applications to Python 3 during the Liberty cycle. The following table gives the status of each application and links to patches:
https://wiki.openstack.org/wiki/Python3#OpenStack_applications

Specs were accepted for:

* heat: https://review.openstack.org/#/c/175340/
* keystone: https://review.openstack.org/#/c/177380/
* neutron: https://review.openstack.org/#/c/172962/
* nova: https://review.openstack.org/176868

For cinder, I ported the last blocking dependency to Python 3, rtslib-fb:
https://github.com/agrover/rtslib-fb/pull/62
(There is not release including the fix yet.)

MySQL-python should be replaced with PyMySQL to run Python 3 tests, as done in Ironic, Nova and other applications.

I started to write patches to port Cinder code to Python 3:
https://review.openstack.org/#/q/project:openstack/cinder+branch:master+topic:py3,n,z

Duncan Thomas rejected one of my patch:
"As commented on https://review.openstack.org/#/c/185411/ I'd really like to be convinced that there's an end in sight for this python3 work, or I'm going to start rejecting it. This change is making the code noticeably harder to read, and has no checks to stop it recurring in future, and is lacking substantial justification as to it's benefits."

In the other issue, he wrote:
"""
Is there a master list of remaining python3 issues anywhere? At the moment we are introducing more and more little changes into the code, including some really ugly six stuff, without any idea if we are even close to actually being able to work with python3.

To be honest, I think that I'd like to see a working python3 tree before we merge any more - we can then pull in the fixes in a clean manner, knowing the end-goal is possible.

Thoughts appreciated, otherwise I'm tempted to start hitting -2 on python3 stuff.
"""

Ok, I checked the status of Cinder port to Python 3.

I merged my pending patches into a local branch and I fixed manually dependencies for tox -e py34 (replace MySQL-python with PyMySQL, install the development version of oslo.vmware). With 4 minor changes, I'm able to run one cinder unit test (cinder/tests/unit/test_quota.py). Cool!

The next step will be to run a subset of tests in "tox -e py34" to make it pass, and then add a checking job. When the job becomes stable, make it voting to avoid further Python 3 regressions.

Then more code should be ported to Python 3 to slowly port the whole Cinder code base.

Well, that's exactly the plan approved for Nova, and other OpenStack applications have the same (or a similar) plan for Python 3.

About the usage of six: we chose six to add Python 3 support to all other OpenStack libraries and applications. Sorry if it makes the code "more ugly". More information on porting code to Python 3:
https://wiki.openstack.org/wiki/Python3#Port_Python_2_code_to_Python_3

Victor Stinner aka haypo



More information about the OpenStack-dev mailing list