[nova][dev] Fixing eventlet monkey patching in Nova

Matthew Booth mbooth at redhat.com
Mon Mar 18 12:04:52 UTC 2019

On Fri, 15 Mar 2019 at 19:00, Chris Dent <cdent+os at anticdent.org> wrote:
> On Fri, 15 Mar 2019, Ben Nemec wrote:
> > According to [0], the monkey-patching wasn't done in nova/__init__.py because
> > it was supposed to be able to run without eventlet under WSGI. If that's not
> > the case, then it's probably fine to do it there.
> >
> > 0:
> > http://specs.openstack.org/openstack/openstack-specs/specs/eventlet-best-practices.html
> >
> > "Monkey patching should also be done in a way that allows services to run
> > without it, such as when an API service runs under Apache. This is the reason
> > for Nova not simply monkey patching in nova/__init__.py."
> Yeah, I think several people have run through the eventlet
> initialization at various times, including me, with various results,
> none of them quite good enough.
> The mod_wsgi/uwsgi side of things strived to be eventlet free as it
> makes for weirdness, and at some point I did some work to be sure it
> never showed up in placement [1] while it was still in nova. A side
> effect of that work was that it also didn't need to show up in the
> nova-api unless you used the cmd line script version of it. At the
> same time I also explored not importing the world, and was able to
> get some improvements (mostly by moving things out of __init__.py in
> packages that had deeply nested members) but not as much as would
> have liked.
> However, we later (as mentioned elsewhere in the thread) made
> getting cell mappings parallelize, bring back the need for eventlet,
> it seems.
> >> TL;DR I want to move monkey patching to nova/__init__.py because, for
> >> now at least, we always require it anyway. When we eventually remove
> >> the requirement for wsgi services to monkey patch we can move monkey
> >> patching back to nova/cmd/__init__.py.
> >
> > This sounds fine to me, but it's been a loooong time since I looked at this
> > and I'm not familiar with some of the more recent changes you talked about,
> > so take my opinion with a grain of salt.
> This does seem like the expedient solution (assuming it works), but
> if we continue to use eventlet anywhere in the api service it will
> continue to introduce difficulties and inflexibility with deployment
> choices as it will interact poorly with at least some of the
> web-servers that could be chosen to run the nova API.

Thanks for the feedback, folks.

I appreciate the desire to drop eventlet entirely (elsewhere in this
thread) but as has also been noted that's not a short term option.
Probably feasible for U, though, and lets keep it in mind. On that
note, my preference for multi-threaded in Nova has always been to use
Python's own apis except when that's not possible. Eventlet monkey
patches these to do its own thing when it's in use, and when not using
eventlet this obviously works fine.

I think I'm hearing that moving monkey patching to the top level is
the right solution for now. I'm going to go ahead and knock that up.

Matthew Booth
Red Hat OpenStack Engineer, Compute DFG

Phone: +442070094448 (UK)

More information about the openstack-discuss mailing list