Nova API returns unicode Location Header

Bug #1235220 reported by Jesse Pretorius
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Invalid
Medium
Sujitha
Ubuntu
Confirmed
Undecided
Unassigned

Bug Description

The Nova Compute API returns a series of headers as a result of create operation. The location header is being returned as a unicode value which is not compliant with the RFC for HTTP.

I haven't figured out yet whether this is a global thing or specific to something more localised.

While not a problem when running with nova-api services directly the problem manifests itself if a user was to front the API with something that requires rfc compliant headers to be returned, such as Apache.

Eg execute: nova image-create 69136d40-8de0-4a63-b03a-16543d390c8e test-snap-20131004-10

Response:
ERROR: <attribute 'message' of 'exceptions.BaseException' objects> (HTTP 500)

Apache's error log shows:
[Fri Oct 04 14:08:42 2013] [error] [client 192.168.4.63] mod_wsgi (pid=20280): Exception occurred processing WSGI script '/etc/apache2/wsgi/nova-api-os-compute'.
[Fri Oct 04 14:08:42 2013] [error] [client 192.168.4.63] TypeError: expected byte string object for header value, value of type unicode found

The actual image-create ends up being successful, even though the client receives a HTTP 500 response.

Environment: Openstack Grizzly on Ubuntu with package level 2013.1.3

While this is the same result as https://bugs.launchpad.net/nova/+bug/938114 It appears to me that this is more localised.

Tags: api
description: updated
Revision history for this message
Jesse Pretorius (jesse-pretorius) wrote :

The following simple patch sorted the issue out for me:

root@api2:~# diff servers.py /usr/lib/python2.7/dist-packages/nova/api/openstack/compute/servers.py
1382c1382
< resp.headers['Location'] = image_ref
---
> resp.headers['Location'] = image_ref.encode('utf-8')

tags: added: api
Changed in nova:
status: New → Confirmed
importance: Undecided → Medium
assignee: nobody → Christopher Yeoh (cyeoh-0)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/51812

Changed in nova:
status: Confirmed → In Progress
Revision history for this message
Christopher Yeoh (cyeoh-0) wrote :

Jesse - I'm just trying to track down exactly where the unicode is coming from. Is there unicode in the domain names of the servers hosting your openstack services?

Revision history for this message
Jesse Pretorius (jesse-pretorius) wrote :

Christopher - The domain name was api.cloudbuilder.co.za and the rest of the URI was standard for the service. It may simply be that one of the libraries being used defaults to using a unicode header.

Matt Riedemann (mriedem)
Changed in nova:
status: In Progress → Triaged
assignee: Christopher Yeoh (cyeoh-0) → nobody
Changed in nova:
assignee: nobody → Christopher Yeoh (cyeoh-0)
status: Triaged → In Progress
Revision history for this message
Christopher Yeoh (cyeoh-0) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in ubuntu:
status: New → Confirmed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on nova (master)

Change abandoned by Sean Dague (<email address hidden>) on branch: master
Review: https://review.openstack.org/51812
Reason: This review is > 4 weeks without comment, and failed Jenkins the last time it was checked. We are abandoning this for now. Feel free to reactivate the review by pressing the restore button and leaving a 'recheck' comment to get fresh test results.

Revision history for this message
Davanum Srinivas (DIMS) (dims-v) wrote :

Removing "In Progress" status and assignee as change is abandoned.

Changed in nova:
assignee: Christopher Yeoh (cyeoh-0) → nobody
status: In Progress → Confirmed
Sujitha (sujitha-neti)
Changed in nova:
assignee: nobody → Sujitha (sujitha-neti)
Revision history for this message
Sujitha (sujitha-neti) wrote :

I'm not able to replicate the bug. Its working as expected. I installed devstack on Ubuntu and changed configurations to run nova-api with apache2.

Command: nova image-create myinstance testImage
Output: Image was created with out any error and can be seen using nova image-list.

Also, the debug log displayed Content-Type: text/html; charset=UTF-8 for the image-create response. So it is returning it in utf-8. So I think this bug is no longer valid.

Changing it to invalid.

Sujitha (sujitha-neti)
Changed in nova:
status: Confirmed → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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