[openstack-dev] [nova] Placement API WSGI code -- let's just use flask
soulxu at gmail.com
Thu Jun 23 03:16:21 UTC 2016
2016-06-22 22:52 GMT+08:00 Chris Dent <cdent+os at anticdent.org>:
> On Tue, 21 Jun 2016, Sean Dague wrote:
> I honestly don't think raw WSGI is a bad choice here. People are going
>> to be pretty familiar with it in related projects at this level.
> Yeah, WSGI itself is a framework, one that is clearly defined and works
> well for the types of things we are currently trying to do in HTTP
> because for the most part what we are doing is really really really
> simple and ought to require vanishingly small amounts of code.
> Using selector instead of Routes makes things different for unclear
>> gain. Sticking with Routes seems more prudent.
> I'm not willing to fight about it, but I really think Routes has
> very bad taste when it comes to both WSGI and Python, probably at
> least in part because of its inspiration in Rails.
> Selector is WSGI middleware that does routing and dispatch to other
> WSGI middleware or apps using easy to read and _explicit_ code that
> is Pythonic.
> class MySelectorDispatchingWSGIApp(object):
> def __init__(self):
> self._selector = Selector()
> def __call__(self, environ, start_response):
> return self._selector(environ, start_response)
> But okay, fine, if people think that's too scary and that change is
> bad we can use something else.
> Doing Flask is fine, but do it because we think that's the way things
>> should be done, not because it's a common in our community, which it
>> clearly is not. The common pattern is custom WSGI + Routes / Paste (at
>> least at this layer in the stack).
> Because something is a common pattern that doesn't make it correct
> or good. Many of the conversations about evoluting OpenStack in the
> large and at the detail level seem to forget this. "That's the way
> we've always done it" is painfully conservative and regressive and
> witnessing people saying it (again and again) is depressing and
> demotivating and says terrible things about the future of OpenStack.
> Obviously we shouldn't be willy nilly causing change and churn in
> existing code without good reason, but in new stuff, exploring the
> options is not just good for the health and correctness of the
> services it is also good for the health of the community.
> But, as I've said elsewhere, what I want most is consensus. I'd prefer
> a consensus to do something well instead of one to do something in a
> mediocre fashion. I hope getting to at least good is why these
> discussions are continuing.
> What I would like from the placement code that will eventually
> result from this is:
> * code that operates with minimal configuration and has zero knobs
> exposed to deployers that shouldn't be turned (therefore no
> * code that is simple to read, avoids excessive indirection and
> subclassing, and has clearly illuminated flows of control (minimal
> magic, minimal action at a distance, WSGI apps as functions not
> * code that, by virtue of both of the above and being created using
> TDD, is easy to test
> To _me_, and strong opinions will differ, this especially discounts
> using the pre-existing Nova WSGI model. It somewhat discounts using Flask
> because of the globals (g etc) that proxy to request and app level
> information but at least Flask is a common popular thing, so it has
> that going for it.
> You're right, Sean, when you say elsewhere in this thread that the
> amount of "framework" stuff in my existing code is pretty minimal.
> That's because the API is simple. The code should reflect that, it
> does that by just being WSGI stuff.
I also agree with the WSGI framework actually is very simple and minimal.
And look at the nova api code, I didn't remember we changed the code in
past few releases. The complex thing is the framework for REST API App, the
framework need to support microversion, input validation, even
documentation. So i'm thinking whether easy to support microversion in
Flask, does Flask provide input validation and documentation? If not, I
didn't think Flask provide too much benefit to us than custom WSGI
>  The current code does use paste.ini because that was the fastest
> way to get working code running in the existing nova test environment
> but a variety of people have said we should get rid of it and I
> agree. Getting working code running is what has allowed this
> conversation to happen and despite the meandering I think it is
> Chris Dent (╯°□°)╯︵┻━┻ http://anticdent.org/
> freenode: cdent tw: @anticdent
> OpenStack Development Mailing List (not for usage questions)
> Unsubscribe: OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the OpenStack-dev