[openstack-dev] [all] [glance] python namespaces considered harmful to development, lets not introduce more of them

Sean Dague sean at dague.net
Wed Aug 27 15:44:28 UTC 2014


On 08/27/2014 11:14 AM, Flavio Percoco wrote:
> On 08/27/2014 04:31 PM, Sean Dague wrote:
>> So this change came in with adding glance.store -
>> https://review.openstack.org/#/c/115265/5/lib/glance, which I think is a
>> bad direction to be headed.
>>
>> Here is the problem when it comes to working with code from git, in
>> python, that uses namespaces, it's kind of a hack that violates the
>> principle of least surprise.
>>
>> For instance:
>>
>> cd /opt/stack/oslo.vmware
>> pip install .
>> cd /opt/stack/olso.config
>> pip install -e .
>> python -m olso.vmware
>> /usr/bin/python: No module named olso.vmware
>>
>> In python 2.7 (using pip) namespaces are a bolt on because of the way
>> importing modules works. And depending on how you install things in a
>> namespace will overwrite the base __init__.py for the top level part of
>> the namespace in such a way that you can't get access to the submodules.
>>
>> It's well known, and every conversation with dstuft that I've had in the
>> past was "don't use namespaces".
>>
>> A big reason we see this a lot is due to the fact that devstack does
>> 'editable' pip installs for most things, because the point is it's a
>> development environment, and you should be able to change code, and see
>> if live without having to go through the install step again.
>>
>> If people remember the constant issues with oslo.config in unit tests 9
>> months ago, this was because of mismatch of editable vs. non editable
>> libraries in the system and virtualenvs. This took months to get to a
>> consistent workaround.
>>
>> The *workaround* that was done is we just gave up on installing olso
>> libs in a development friendly way. I don't consider that a solution,
>> it's a work around. But it has some big implications for the usefulness
>> of the development environment. It also definitely violates the
>> principle of least surprise, as changes to oslo.messaging in a devstack
>> env don't immediately apply, you have to reinstall olso.messaging to get
>> them to take.
>>
>> If this is just oslo, that's one thing (and still something I think
>> should be revisted, because when the maintainer of pip says "don't do
>> this" I'm inclined to go by that). But this change aims to start brining
>> this pattern into other projects. Realistically I'm quite concerned that
>> this will trigger more work arounds and confusion.
>>
>> It also means, for instance, that once we are in a namespace we can
>> never decide to install some of the namespace from pypi and some of it
>> from git editable (because it's a part that's under more interesting
>> rapid development).
>>
>> So I'd like us to revisit using a namespace for glance, and honestly,
>> for other places in OpenStack, because these kinds of violations of the
>> principle of least surprise is something that I'd like us to be actively
>> minimizing.
> 
> 
> Sean,
> 
> Thanks for bringing this up.
> 
> To be honest, I became familiar with these namespace issues when I
> started working on glance.store. That said, I realize how this can be an
> issue even with the current "workaround".
> 
> Unfortunately, it's already quite late in the release and starting the
> rename process will delay Glance's migration to glance.store leaving us
> with not enough time to test it and make sure things are working as
> expected.
> 
> With full transparency, I don't have an counter-argument for what you're
> saying/proposing. I talked to Doug on IRC and he mentioned this is
> something that won't be fixed in py27 so there's not even hope on seeing
> it fixed/working soon. Based on that, I'm happy to rename glance.store
> but, I'd like us to think in a good way to make this rename happen
> without blocking the glance.store work in Juno.
> 
> I've 2 ways to make this happen:
> 
> 1. Do a partial rename and then complete it after the glance migration
> is done. If I'm not missing anything, we should be able to do something
> like:
> 	- Rename the project internally
> 	- Release a new version with the new name `glancestore`
> 	- Switch glance over to `glancestore`
> 	- Complete the rename process with support from infra
> 
> 2. Let this patch land, complete Glance's switch-over using namespaces
> and then do the rename all together.
> 
> Do you have any other suggestion that would help avoiding namespaces
> without blocking glance.store?

I think those are the 2 paths. I think path #1 is completely sane. All
it will mean is that the repo name isn't exactly the package name, but I
think that's fine. We can take the repo name later in the release cycle.
So I'm really pro #1 if you can do that.

Because I really fear digging deeper here on namespaces and trying to
reverse them later. Given that we're still talking about largely
"unreleased" glance code that uses it (for the non CD case) getting the
internals straightened up fastest is I think the best win here.

Sorry for only realizing what was going on so late. I had an incorrect
grasp of where we all stood on the namespace issue (I think most of the
past discussion of these issues and resolutions were in
#openstack-infra, so while logged, not nearly so visible as an ML
thread), so it really only occurred to me this morning that glance.store
was actually going to bring in new namespaces.

	-Sean

-- 
Sean Dague
http://dague.net



More information about the OpenStack-dev mailing list