Glance v2 image create requires body in request

Bug #1130961 reported by Nathan Biles
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance Client
Fix Released
Undecided
Unassigned

Bug Description

When running tempest test (nosetests /tmp/tempest/tempest/tempest/tests/image), the tests are showing new errors when running with glance v2 because they do not add a body to the request. Not sure if change in behavior for glance api v2 is an enhancement or a regression. Anyway, here is the out from the test:
=============
requests.packages.urllib3.connectionpool: INFO: Starting new HTTP connection (1): 127.0.0.1
requests.packages.urllib3.connectionpool: DEBUG: "POST /v2.0/tokens HTTP/1.1" 200 2500
tempest.services.image.json.image_client: INFO: Request: POST http://192.168.4.173:9292/v2/images
tempest.services.image.json.image_client: DEBUG: Request Headers: {'x-image-meta-container_format': 'bare', 'x-image-meta-location': 'http://example.com/someimage.iso', 'X-Auth-Token': u'56110e2098f94b9f8b99bdf9d850069f', 'x-image-meta-is_public': 'True', 'x-image-meta-disk_format': 'raw', 'x-image-meta-name': 'New Remote Image'}
tempest.services.image.json.image_client: INFO: Response Status: 400
tempest.services.image.json.image_client: DEBUG: Response Headers: {'date': 'Wed, 20 Feb 2013 20:52:42 GMT', 'content-length': '47', 'content-type': 'text/plain; charset=UTF-8', 'x-openstack-request-id': 'req-a6f5050c-56b9-48c5-afd2-4722a3be0a37'}
tempest.services.image.json.image_client: DEBUG: Response Body: 400 Bad Request

Body expected in request.

Revision history for this message
Brian Waldon (bcwaldon) wrote :

The first thing I notice is that tempest is talking to a v2 endpoint yet sending the v1 headers. Additionally, if the client is sending application/json as the content type, then I do not thing this is a Glance bug. On the other hand, if the client is sending no data, and therefore no content-type, then this is a bug in Glance. Can you provide some more info here?

Changed in python-glanceclient:
status: New → Incomplete
Revision history for this message
Nathan Biles (npbiles) wrote :

I believe the request content-type is set in glance_http.py here:

    def raw_request(self, method, url, **kwargs):
        kwargs.setdefault('headers', {})
        kwargs['headers'].setdefault('Content-Type', 'application/octet-stream')

However, no body is being set.

Also how can you tell it's a v1 header? Is the v1 vs v2 format documented somewhere

Nathan Biles (npbiles)
Changed in python-glanceclient:
status: Incomplete → In Progress
Nathan Biles (npbiles)
Changed in python-glanceclient:
status: In Progress → New
Revision history for this message
Jeff Marcom (jeffmarcom) wrote :

Same issue reported here:
DEBUG:root:Meta data creation succesful
DEBUG:root:Attempting upload of image...
DEBUG:root:b5ec07e7-6709-4fe4-a497-2b94c0aed9d6
DEBUG:root:{'x-image-name': 'certification', 'X-Auth-Token': '0e02ba7abf2942a58f974560d101d9d3'}
INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 192.168.1.7
DEBUG:requests.packages.urllib3.connectionpool:"POST /v2/images HTTP/1.1" 400 151
DEBUG:root:400
DEBUG:root:<html>
 <head>
  <title>400 Bad Request</title>
 </head>
 <body>
  <h1>400 Bad Request</h1>
  Body expected in request.<br /><br />

Revision history for this message
Jeff Marcom (jeffmarcom) wrote :

I believe the workaround for this may be to issue a "PUT" to v2/images/<image-id>/file. This worked for me, although now I'm blocked by bug#1069979

Revision history for this message
Ian Cordasco (icordasc) wrote :

There's been no activity on this since 2013. It's safe to assume this has been fixed and released.

Changed in python-glanceclient:
status: New → Fix Released
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.