ceilometerclient handles exceptions from session object in wrong way

Bug #1620974 reported by Andriy Kurilin
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-ceilometerclient
Fix Released
Undecided
Andriy Kurilin

Bug Description

Way to initialize ceilometerclient: transmit keystone session object
Context: something went wrong and request returns status_code >= 400
Expected behaviour: raise user friendly error
Actual behaviour: AttributeError: 'Response' object has no attribute 'status'

This bug was detected by porting Rally to initialize ceilometerclient with keystone session(unified way to initialize all clients).

What actually happens in the ceilometerclient code:
1) if error occurs, ceilometerclient checks status_code and raise_exc argument(Defaults to True) and calls from_response method to find the proper exception - https://github.com/openstack/python-ceilometerclient/blob/7c6cc05ff0e9e95313384303deee69ef11929bc1/ceilometerclient/client.py#L472-L473
2) from_response method expects httplib response object, so it checks "status" property which is wrong in case of response from SessionClient
https://github.com/openstack/python-ceilometerclient/blob/7c6cc05ff0e9e95313384303deee69ef11929bc1/ceilometerclient/exc.py#L120-L123

Changed in python-ceilometerclient:
assignee: nobody → Andrey Kurilin (andreykurilin)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-ceilometerclient (master)

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

Changed in python-ceilometerclient:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-ceilometerclient (stable/newton)

Fix proposed to branch: stable/newton
Review: https://review.openstack.org/366638

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-ceilometerclient (master)

Reviewed: https://review.openstack.org/366633
Committed: https://git.openstack.org/cgit/openstack/python-ceilometerclient/commit/?id=1b1917ab9b56fe92235ce336d3df3e7a8c1c81d2
Submitter: Jenkins
Branch: master

commit 1b1917ab9b56fe92235ce336d3df3e7a8c1c81d2
Author: Andrey Kurilin <email address hidden>
Date: Wed Sep 7 12:39:12 2016 +0300

    Fix from_response method to process response from requests

    SessionClient uses requests library. It's response class doesn't have
    "status" property[1], so in case of any errors(with status code > 400),
    from_response method is called and raises AttributeError.

    Also, HTTPClient implementation uses requests lib by default[2](if 'http'
    argument was not transmitted), so from_response method will raise
    AttributeError too.

    [1] - http://docs.python-requests.org/en/master/api/#requests.Response.status_code
    [2] - https://github.com/openstack/python-ceilometerclient/blob/2.6.0/ceilometerclient/openstack/common/apiclient/client.py#L99-L100

    Change-Id: Id8fb2f386e8101951716f30a6365c9aa15bd4b24
    Closes-Bug: #1620974

Changed in python-ceilometerclient:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-ceilometerclient (stable/newton)

Reviewed: https://review.openstack.org/366638
Committed: https://git.openstack.org/cgit/openstack/python-ceilometerclient/commit/?id=090e5ffc691c5d40e45ab0c20dc88032a0987b20
Submitter: Jenkins
Branch: stable/newton

commit 090e5ffc691c5d40e45ab0c20dc88032a0987b20
Author: Andrey Kurilin <email address hidden>
Date: Wed Sep 7 12:39:12 2016 +0300

    Fix from_response method to process response from requests

    SessionClient uses requests library. It's response class doesn't have
    "status" property[1], so in case of any errors(with status code > 400),
    from_response method is called and raises AttributeError.

    Also, HTTPClient implementation uses requests lib by default[2](if 'http'
    argument was not transmitted), so from_response method will raise
    AttributeError too.

    [1] - http://docs.python-requests.org/en/master/api/#requests.Response.status_code
    [2] - https://github.com/openstack/python-ceilometerclient/blob/2.6.0/ceilometerclient/openstack/common/apiclient/client.py#L99-L100

    Change-Id: Id8fb2f386e8101951716f30a6365c9aa15bd4b24
    Closes-Bug: #1620974
    (cherry picked from commit 1b1917ab9b56fe92235ce336d3df3e7a8c1c81d2)

tags: added: in-stable-newton
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/python-ceilometerclient 2.6.1

This issue was fixed in the openstack/python-ceilometerclient 2.6.1 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/python-ceilometerclient 2.7.0

This issue was fixed in the openstack/python-ceilometerclient 2.7.0 release.

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.