when placement API sends a 405 the header value is in the incorrect format

Bug #1626496 reported by Chris Dent
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Low
Chris Dent

Bug Description

When the placement handlers raise an HTTPMethodNotAllowed response, the headers are set with those methods that are allowed. These need to be not unicode (it's not clear how they get to be unicode (in 2.7) in the first place, but something is doing it, and that's not right) otherwise we get:

```
2016-09-22 11:03:01.875 22919 ERROR nova.api.openstack.placement.handler HTTPMethodNotAllowed: The method specified is not allowed for this resource.
2016-09-22 11:03:01.875 22919 ERROR nova.api.openstack.placement.handler
2016-09-22 11:03:01.877 22919 INFO nova.api.openstack.placement.requestlog [req-524fdd42-0f19-4eb3-827f-99ae22fc6dd9 admin admin] 10.0.2.15 "DELETE /placement/resource_providers" status: 405 len: 133
mod_wsgi (pid=22919): Exception occurred processing WSGI script '/usr/local/bin/nova-placement-api'.
TypeError: expected byte string object for header value, value of type unicode found
```

wherein the service correctly tries to send a 405 but then the mod_wsgi server blows up on the data it is getting.

Revision history for this message
Chris Dent (cdent) wrote :

I'm not sure why this hasn't updated from gerrit, this is in progress at https://review.openstack.org/#/c/374800/

Changed in nova:
assignee: nobody → Chris Dent (cdent)
status: New → In Progress
Changed in nova:
importance: Undecided → Low
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/374800
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=5fdb9226d269af069bfcbd42cff401c9d089b7dd
Submitter: Jenkins
Branch: master

commit 5fdb9226d269af069bfcbd42cff401c9d089b7dd
Author: Chris Dent <email address hidden>
Date: Thu Sep 22 12:58:41 2016 +0000

    [placement] ensure that allow headers are native strings

    mod-wsgi checks that response header values are what's described
    as "native strings". This means whatever `str` is in either
    python 2 or 3, but never `unicode`. When they are not mod-wsgi
    will 500. For the most part this is taken care of by webob, but in
    the case of the 405 handling, the webob response is not being
    fully massaged.

    mod-wsgi is doing this because it supposed to. Python WSGI server
    gateways have different expectations of headers depending on whether
    the Python is 2 or 3. See

    https://www.python.org/dev/peps/pep-3333/#a-note-on-string-types

    In addition to the unit test, the gabbi tests are now using a
    version of wsgi-intercept that will raise a TypeError when the
    application response headers are not using the correct form. This
    check needs to be done in wsgi-intercept rather than the gabbi tests
    because both wsgi-intercept and the http client makes requests
    transform the headers for their own purposes.

    This fix ensures that instead of a 500 the correct 405 response
    happens.

    Closes-Bug: #1626496
    Depends-On: I3b8aabda929fe39b60e645abb6fabb9769554829
    Change-Id: Ifa436e11e79adc2e159b4c5e7d3623d9a792b5f7

Changed in nova:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/nova 15.0.0.0b1

This issue was fixed in the openstack/nova 15.0.0.0b1 development milestone.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.