Stray ProtocolError can lead to stack trace

Bug #1526254 reported by Stuart McLaren
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance Client
Fix Released
Medium
Monty Taylor
Liberty
Fix Committed
Medium
Flavio Percoco

Bug Description

We have a try/except which catches ProtocolError. This leads to:

 Couldn't construct image object
 Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/shade/openstackcloud.py", line 254, in _get_client
    **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/os_client_config/cloud_config.py", line 300, in get_legacy_client
    return client_class(*constructor_args, **constructor_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/glanceclient/client.py", line 59, in Client
    module = utils.import_versioned_module(int(version), 'client')
  File "/usr/local/lib/python2.7/dist-packages/glanceclient/common/utils.py", line 281, in import_versioned_module
    return importutils.import_module(module)
  File "/usr/local/lib/python2.7/dist-packages/oslo_utils/importutils.py", line 73, in import_module
    __import__(import_str)
  File "/usr/local/lib/python2.7/dist-packages/glanceclient/v2/__init__.py", line 15, in <module>
    from glanceclient.v2.client import Client # noqa
  File "/usr/local/lib/python2.7/dist-packages/glanceclient/v2/client.py", line 17, in <module>
    from glanceclient.common import http
  File "/usr/local/lib/python2.7/dist-packages/glanceclient/common/http.py", line 26, in <module>
    ProtocolError = requests.packages.urllib3.exceptions.ProtocolError
 AttributeError: 'module' object has no attribute 'packages'
 Error fetching image list: 'module' object has no attribute 'packages'

From Ian:

I think the whole try/except block here is just wrong given the current requirement on requests (https://git.openstack.org/cgit/openstack/python-glanceclient/tree/requirements.txt#n9).
This popped up in a much older version of requests where urllib3 added the ProtocolError and then started using it and requests missed its addition and it bubbled up. There should not be any reason to continue doing this silly try/except. We should just replace the usage of ProtocolError with requests.exceptions.ConnectioneError.

Revision history for this message
Stuart McLaren (stuart-mclaren) wrote :
Changed in python-glanceclient:
status: New → Confirmed
Revision history for this message
Stuart McLaren (stuart-mclaren) wrote :

Marked as confirmed based on the stack trace provided in the review comment:

https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/ansible-project/KyDhWJmjgpI/h7KiP58ACQAJ

Changed in python-glanceclient:
importance: Undecided → Medium
assignee: nobody → Monty Taylor (mordred)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-glanceclient (stable/liberty)

Fix proposed to branch: stable/liberty
Review: https://review.openstack.org/257871

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

Reviewed: https://review.openstack.org/257558
Committed: https://git.openstack.org/cgit/openstack/python-glanceclient/commit/?id=9bc0018eda5c16ca5e7a10db722cb6b08445f0fa
Submitter: Jenkins
Branch: master

commit 9bc0018eda5c16ca5e7a10db722cb6b08445f0fa
Author: Monty Taylor <email address hidden>
Date: Mon Dec 14 15:22:52 2015 -0500

    Remove broken try/except workaround for old requests

    Not only is this code broken on the requests we require on
    distro-provided requests, it's not needed anymore. Remove it.

    Closes-bug: 1526254

    Change-Id: I47a07bf9910f118392785fc20e015f036a2e8a7c

Changed in python-glanceclient:
status: Confirmed → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-glanceclient (stable/liberty)

Reviewed: https://review.openstack.org/257871
Committed: https://git.openstack.org/cgit/openstack/python-glanceclient/commit/?id=89e4476df77bf47705a84003ff2084198ff0c40c
Submitter: Jenkins
Branch: stable/liberty

commit 89e4476df77bf47705a84003ff2084198ff0c40c
Author: Monty Taylor <email address hidden>
Date: Mon Dec 14 15:22:52 2015 -0500

    Remove broken try/except workaround for old requests

    Not only is this code broken on the requests we require on
    distro-provided requests, it's not needed anymore. Remove it.

    Closes-bug: 1526254

    Change-Id: I47a07bf9910f118392785fc20e015f036a2e8a7c

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

This issue was fixed in the openstack/python-glanceclient 1.1.1 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.