Ironicclient throws 'AttributeError' instead of 'Unauthorized' exception when encountering 401 from Keystone

Bug #1402840 reported by Clif Houck
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
oslo-incubator
Fix Released
Medium
Davanum Srinivas (DIMS)
python-ironicclient
Fix Released
Medium
Ruby Loo

Bug Description

Ironic client is throwing a low-level AttributeError when encountering a 401 unauthorized instead of throwing an 'Unauthorized' exception.

See the following log for specifics:

014-12-12 23:23:10.528 DEBUG nova.openstack.common.loopingcall [-] Dynamic looping call <bound method Service.periodic_tasks of <nova.service.Service object at 0x7f370691a890>> sleeping for 5.00 seconds from (pid=13816) _inner /opt/stack/nova/nova/openstack/common/loopingcall.py:132
2014-12-12 23:23:15.528 DEBUG nova.openstack.common.periodic_task [-] Running periodic task ComputeManager.update_available_resource from (pid=13816) run_periodic_tasks /opt/stack/nova/nova/openstack/common/periodic_task.py:199
2014-12-12 23:23:15.529 DEBUG ironicclient.common.http [-] curl -i -X GET -H 'X-Auth-Token: 208913b4cc0749cfaf1a9f135b6334bc' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'User-Agent: python-ironicclient' http://104.130.225.74:6385/v1/nodes/detail from (pid=13816) log_curl_request /usr/local/lib/python2.7/dist-packages/ironicclient/common/http.py:109
2014-12-12 23:23:15.532 DEBUG ironicclient.common.http [-]
HTTP/1.0 401 Unauthorized
date: Fri, 12 Dec 2014 23:23:15 GMT
content-length: 23
content-type: text/plain
www-authenticate: Keystone uri='http://104.130.225.74:5000/v2.0'
server: WSGIServer/0.1 Python/2.7.6

Authentication required
 from (pid=13816) log_http_response /usr/local/lib/python2.7/dist-packages/ironicclient/common/http.py:119
2014-12-12 23:23:15.532 WARNING ironicclient.common.http [-] Request returned failure status.
2014-12-12 23:23:15.532 ERROR nova.openstack.common.periodic_task [-] Error during ComputeManager.update_available_resource: HTTPResponse instance has no attribute 'text'
2014-12-12 23:23:15.532 TRACE nova.openstack.common.periodic_task Traceback (most recent call last):
2014-12-12 23:23:15.532 TRACE nova.openstack.common.periodic_task File "/opt/stack/nova/nova/openstack/common/periodic_task.py", line 204, in run_periodic_tasks
2014-12-12 23:23:15.532 TRACE nova.openstack.common.periodic_task task(self, context)
2014-12-12 23:23:15.532 TRACE nova.openstack.common.periodic_task File "/opt/stack/nova/nova/compute/manager.py", line 6020, in update_available_resource
2014-12-12 23:23:15.532 TRACE nova.openstack.common.periodic_task nodenames = set(self.driver.get_available_nodes())
2014-12-12 23:23:15.532 TRACE nova.openstack.common.periodic_task File "/opt/stack/nova/nova/virt/ironic/driver.py", line 472, in get_available_nodes
2014-12-12 23:23:15.532 TRACE nova.openstack.common.periodic_task self._refresh_cache()
2014-12-12 23:23:15.532 TRACE nova.openstack.common.periodic_task File "/opt/stack/nova/nova/virt/ironic/driver.py", line 453, in _refresh_cache
2014-12-12 23:23:15.532 TRACE nova.openstack.common.periodic_task node_list = self.ironicclient.call('node.list', detail=True, limit=0)
2014-12-12 23:23:15.532 TRACE nova.openstack.common.periodic_task File "/opt/stack/nova/nova/virt/ironic/client_wrapper.py", line 119, in call
2014-12-12 23:23:15.532 TRACE nova.openstack.common.periodic_task return self._multi_getattr(client, method)(*args, **kwargs)
2014-12-12 23:23:15.532 TRACE nova.openstack.common.periodic_task File "/usr/local/lib/python2.7/dist-packages/ironicclient/v1/node.py", line 88, in list
2014-12-12 23:23:15.532 TRACE nova.openstack.common.periodic_task limit=limit)
2014-12-12 23:23:15.532 TRACE nova.openstack.common.periodic_task File "/usr/local/lib/python2.7/dist-packages/ironicclient/common/base.py", line 96, in _list_pagination
2014-12-12 23:23:15.532 TRACE nova.openstack.common.periodic_task resp, body = self.api.json_request('GET', url)
2014-12-12 23:23:15.532 TRACE nova.openstack.common.periodic_task File "/usr/local/lib/python2.7/dist-packages/ironicclient/common/http.py", line 200, in json_request
2014-12-12 23:23:15.532 TRACE nova.openstack.common.periodic_task resp, body_iter = self._http_request(url, method, **kwargs)
2014-12-12 23:23:15.532 TRACE nova.openstack.common.periodic_task File "/usr/local/lib/python2.7/dist-packages/ironicclient/common/http.py", line 183, in _http_request
2014-12-12 23:23:15.532 TRACE nova.openstack.common.periodic_task error_json.get('debuginfo'), method, url)
2014-12-12 23:23:15.532 TRACE nova.openstack.common.periodic_task File "/usr/local/lib/python2.7/dist-packages/ironicclient/exc.py", line 61, in from_response
2014-12-12 23:23:15.532 TRACE nova.openstack.common.periodic_task return exceptions.from_response(response, message, url)
2014-12-12 23:23:15.532 TRACE nova.openstack.common.periodic_task File "/usr/local/lib/python2.7/dist-packages/ironicclient/openstack/common/apiclient/exceptions.py", line 447, in from_response
2014-12-12 23:23:15.532 TRACE nova.openstack.common.periodic_task kwargs["details"] = response.text
2014-12-12 23:23:15.532 TRACE nova.openstack.common.periodic_task AttributeError: HTTPResponse instance has no attribute 'text'

Clif Houck (clifhouck)
Changed in python-ironicclient:
assignee: nobody → Clif Houck (f-te-u)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-ironicclient (master)

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

Changed in python-ironicclient:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-ironicclient (master)

Reviewed: https://review.openstack.org/142204
Committed: https://git.openstack.org/cgit/openstack/python-ironicclient/commit/?id=4017ae76888c3b0a61df9ecacd15d89f039a95b6
Submitter: Jenkins
Branch: master

commit 4017ae76888c3b0a61df9ecacd15d89f039a95b6
Author: Clif Houck <email address hidden>
Date: Tue Dec 16 19:30:56 2014 +0000

    Fix to properly issue an Unauthorized exception

    This change adds a small workaround in exc.py to avoid a situation
    where an HTTP response that has a content-type of 'text/*' but
    no text attribute will trigger an AttributeError exception in
    the openstack.common.apiclient.exceptions module.

    Added a test to make sure the ironic client throws an 'Unauthorized'
    exception when it encounters a 401 Unauthorized HTTP response instead
    of the observed behavior of throwing an inappropriate AttributeError
    exception.

    The workaround mentioned above corrects the tested behavior.

    Change-Id: I930fd61a896f62a2984cca1e4d40e5d89644aa3f
    Partial-Bug: #1402840

Revision history for this message
Ruby Loo (rloo) wrote :

A workaround was added to Ironic (https://review.openstack.org/142204). After the issue is fixed in oslo, we can delete the workaround from Ironic.

Changed in oslo-incubator:
status: New → Confirmed
importance: Undecided → Medium
assignee: nobody → Davanum Srinivas (DIMS) (dims-v)
Dmitry Tantsur (divius)
Changed in python-ironicclient:
importance: Undecided → Medium
Changed in oslo-incubator:
milestone: none → kilo-3
Revision history for this message
Doug Hellmann (doug-hellmann) wrote :

The fix in the incubator is in https://review.openstack.org/144839

Changed in oslo-incubator:
status: Confirmed → Fix Released
Thierry Carrez (ttx)
Changed in oslo-incubator:
milestone: kilo-3 → 2015.1.0
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-ironicclient (master)

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

Changed in python-ironicclient:
assignee: Clif Houck (f-te-u) → Ruby Loo (rloo)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-ironicclient (master)

Reviewed: https://review.openstack.org/182075
Committed: https://git.openstack.org/cgit/openstack/python-ironicclient/commit/?id=7bc4afba485930727782e585343ec9c9df3667cc
Submitter: Jenkins
Branch: master

commit 7bc4afba485930727782e585343ec9c9df3667cc
Author: Ruby Loo <email address hidden>
Date: Mon May 11 20:16:44 2015 +0000

    Revert fix that issues Unauthorized exception

    This reverts the fix to properly issue an Unauthorized
    exception [1] because it was a workaround, and the proper fix
    was made in oslo.incubator [2] and has been sync'd [3].

    [1] I930fd61a896f62a2984cca1e4d40e5d89644aa3f
    [2] I3b9a20174da482f570d02319e68f46dcaa10ca9c
    [3] Iab799c8209872e2faa9ec6d33a426347b6478cce

    Change-Id: Ia3f5695f73bfff19a9f24117fa881e8d9ed039d3
    Closes-Bug: #1402840

Changed in python-ironicclient:
status: In Progress → Fix Committed
Changed in python-ironicclient:
milestone: none → 0.7.0
status: Fix Committed → Fix Released
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.