image_client.py uses raw_request without error handling

Bug #1517536 reported by Steve Linabery
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tempest
Won't Fix
Undecided
Shuquan Huang

Bug Description

https://github.com/openstack/tempest/blob/master/tempest/services/image/v2/json/image_client.py#L151

We're using raw_request method from tempest-lib.common.rest_client here. Unlike the request method, raw_request does not use _error_checker. So if the response status is e.g. 500, you'll get output from config_tempest.py like:

10:17:48 2015-11-18 10:17:48.254 28130 INFO tempest.common.glance_http [-] Response Status: 500
10:17:48 2015-11-18 10:17:48.256 28130 INFO tempest.common.glance_http [-] Response Headers: [('date', 'Wed, 18 Nov 2015 10:17:47 GMT'), ('content-length', '114'), ('content-type', 'text/plain; charset=UTF-8'), ('x-openstack-request-id', 'req-1814bb26-eef1-4cd2-99e1-cb585b612cfd')]
10:17:48 2015-11-18 10:17:48.256 28130 CRITICAL tempest [-] ValueError: dictionary update sequence element #0 has length 26; 2 is required
10:17:48 2015-11-18 10:17:48.256 28130 ERROR tempest Traceback (most recent call last):
10:17:48 2015-11-18 10:17:48.256 28130 ERROR tempest File "tools/config_tempest.py", line 752, in <module>
10:17:48 2015-11-18 10:17:48.256 28130 ERROR tempest main()
10:17:48 2015-11-18 10:17:48.256 28130 ERROR tempest File "tools/config_tempest.py", line 151, in main
10:17:48 2015-11-18 10:17:48.256 28130 ERROR tempest args.image_disk_format)
10:17:48 2015-11-18 10:17:48.256 28130 ERROR tempest File "tools/config_tempest.py", line 543, in create_tempest_images
10:17:48 2015-11-18 10:17:48.256 28130 ERROR tempest disk_format=disk_format)
10:17:48 2015-11-18 10:17:48.256 28130 ERROR tempest File "tools/config_tempest.py", line 577, in find_or_upload_image
10:17:48 2015-11-18 10:17:48.256 28130 ERROR tempest image = _upload_image(client, image_name, image_dest, disk_format)
10:17:48 2015-11-18 10:17:48.256 28130 ERROR tempest File "tools/config_tempest.py", line 732, in _upload_image
10:17:48 2015-11-18 10:17:48.256 28130 ERROR tempest client.store_image_file(image['id'], data)
10:17:48 2015-11-18 10:17:48.256 28130 ERROR tempest File "/home/stack/tempest/tempest/services/image/v2/json/image_client.py", line 154, in store_image_file
10:17:48 2015-11-18 10:17:48.256 28130 ERROR tempest return service_client.ResponseBody(resp, body)
10:17:48 2015-11-18 10:17:48.256 28130 ERROR tempest File "/home/stack/tempest/tempest/common/service_client.py", line 51, in __init__
10:17:48 2015-11-18 10:17:48.256 28130 ERROR tempest self.update(body_data)
10:17:48 2015-11-18 10:17:48.256 28130 ERROR tempest ValueError: dictionary update sequence element #0 has length 26; 2 is required

because the response body is a StringIO.StringIO, not a dict.

Revision history for this message
Matthew Treinish (treinish) wrote :

There is no config_tempest.py in the tools dir:

https://github.com/openstack/tempest/tree/master/tools

are you sure the issue isn't with whatever your script there is doing

Revision history for this message
Steve Linabery (slinabery) wrote :

Good point. For context, RDO uses a downstream-only script called tools/config_tempest.py:
https://github.com/redhat-openstack/tempest/blob/master/tools/config_tempest.py

All we're doing is calling store_image_file from image_client.py as you can see here:
https://github.com/redhat-openstack/tempest/blob/master/tools/config_tempest.py#L732

In our case, glance is throwing 500, and the code is not handling it. When it attempts to use ResponseBody here:
https://github.com/openstack/tempest/blob/master/tempest/services/image/v2/json/image_client.py#L154

'body' is an instance of StringIO.StringIO. So self.update(body_data) fails.

Shuquan Huang (shuquan)
Changed in tempest:
assignee: nobody → Shuquan Huang (shuquan)
Revision history for this message
Joshua White (joshua-l-white) wrote :

Set to In Progress, if you are no longer working on it please unassign and set status accordingly.

Changed in tempest:
status: New → In Progress
Revision history for this message
Ken'ichi Ohmichi (oomichi) wrote :

I am feeling this report should be owned by Glance side because servers should not return HTTP500 respose any cases because of api-wg guideline.

https://github.com/openstack/api-wg/blob/master/guidelines/http.rst#failure-code-clarifications

A 500 Internal Server Error should not be returned to the user for failures due to user error that can be fixed by changing the request on the client side.

So it is better to set this as Won't Fix on Tempest side.

Changed in tempest:
status: In Progress → Won't Fix
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.