barbicanclient does not catch exceptions thrown by "secrets.payload" API

Bug #1595550 reported by Mahesh D N
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-barbicanclient
In Progress
Undecided
Kiran Totad

Bug Description

As per the barbican client documentation, the get secrets APIs will throw below wrapper exceptions for HTTP Errors:

    barbicanclient.exceptions.HTTPAuthError – 401 Responses
    barbicanclient.exceptions.HTTPClientError – 4xx Responses
    barbicanclient.exceptions.HTTPServerError – 5xx Responses

But in the below code snippet, the HTTP errors from "secrets.payload" API are not catched and wrapped with barbicanclient exceptions.
 .
 .
secrets = barbican_client.secrets.get(secrete_reference, u'text/plain')
secret_payload = secrets.payload
 .
 .

Exception Trace for HTTP 500 :
======================================================
  File "/root/cfs_exec_dash/get_secrets_test.py", line 39, in get_secret
    secrets.payload
  File "/usr/lib/python2.7/site-packages/python_barbicanclient-3.3.0-py2.7.egg/barbicanclient/secrets.py", line 188, in payload
    self._fetch_payload()
  File "/usr/lib/python2.7/site-packages/python_barbicanclient-3.3.0-py2.7.egg/barbicanclient/secrets.py", line 259, in _fetch_payload
    payload = self._api._get_raw(payload_url, headers=headers)
  File "/usr/lib/python2.7/site-packages/python_barbicanclient-3.3.0-py2.7.egg/barbicanclient/client.py", line 85, in _get_raw
    return self.request(path, 'GET', *args, **kwargs).content
  File "/usr/lib/python2.7/site-packages/python_barbicanclient-3.3.0-py2.7.egg/barbicanclient/client.py", line 64, in request
    resp = super(_HTTPClient, self).request(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/python_keystoneclient-2.1.1-py2.7.egg/keystoneclient/adapter.py", line 95, in request
    return self.session.request(url, method, **kwargs)
  File "/usr/lib/python2.7/site-packages/python_keystoneclient-2.1.1-py2.7.egg/keystoneclient/utils.py", line 337, in inner
    return func(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/python_keystoneclient-2.1.1-py2.7.egg/keystoneclient/session.py", line 305, in request
    auth_headers = self.get_auth_headers(auth)
  File "/usr/lib/python2.7/site-packages/python_keystoneclient-2.1.1-py2.7.egg/keystoneclient/session.py", line 622, in get_auth_headers
    return auth.get_headers(self, **kwargs)
  File "/usr/lib/python2.7/site-packages/python_keystoneclient-2.1.1-py2.7.egg/keystoneclient/auth/base.py", line 143, in get_headers
    token = self.get_token(session)
  File "/usr/lib/python2.7/site-packages/python_keystoneclient-2.1.1-py2.7.egg/keystoneclient/auth/identity/base.py", line 203, in get_token
    return self.get_access(session).auth_token
  File "/usr/lib/python2.7/site-packages/python_keystoneclient-2.1.1-py2.7.egg/keystoneclient/auth/identity/base.py", line 249, in get_access
    self.auth_ref = self.get_auth_ref(session)
  File "/usr/lib/python2.7/site-packages/python_keystoneclient-2.1.1-py2.7.egg/keystoneclient/auth/identity/v3/base.py", line 190, in get_auth_ref
    authenticated=False, log=False, **rkwargs)
  File "/usr/lib/python2.7/site-packages/python_keystoneclient-2.1.1-py2.7.egg/keystoneclient/session.py", line 506, in post
    return self.request(url, 'POST', **kwargs)
  File "/usr/lib/python2.7/site-packages/python_keystoneclient-2.1.1-py2.7.egg/keystoneclient/utils.py", line 337, in inner
    return func(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/python_keystoneclient-2.1.1-py2.7.egg/keystoneclient/session.py", line 406, in request
    raise exceptions.from_response(resp, method, url)
InternalServerError: An unexpected error prevented the server from fulfilling your request. (HTTP 500) (Request-ID: req-8d1d5e0c-2682-4969-af6f-78df4e35b37d)

Mahesh D N (maheshd2)
Changed in barbican:
assignee: nobody → Mahesh D N (maheshd2)
Revision history for this message
Jeremy Liu (liujiong) wrote :

In which condition did you get this error?

Revision history for this message
Mahesh D N (maheshd2) wrote :

When there is a keystone service outrage. And also when the credentials are wrong. we get HTTP errors that are not wrapped by the barbican client into barbican HTTP Exceptions.

affects: barbican → python-barbicanclient
Changed in python-barbicanclient:
assignee: Mahesh D N (maheshd2) → Kiran Totad (kiran-totad)
Changed in python-barbicanclient:
assignee: Kiran Totad (kiran-totad) → nobody
Changed in python-barbicanclient:
assignee: nobody → Kiran Totad (kiran-totad)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-barbicanclient (master)

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

Changed in python-barbicanclient:
status: New → In Progress
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.