openstackclient fails to add v2 suffix for certain conditions

Bug #1652827 reported by Imtiaz Chowdhury
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python-openstackclient
Fix Released
Medium
Imtiaz Chowdhury

Bug Description

To support v2 image API endpoints, openstackclient currently appends '/v2' to the endpoint URL. The code that adds this suffix is here: https://github.com/openstack/python-openstackclient/blob/master/openstackclient/api/image_v2.py#L26

However, the logic here fails to work when the hostname itself has a 'v2' in its name. For example, if the hostname is 'myhost.rackv20.com' then the logic in L26 evaluates to False and not append any suffix.

Perhaps a better implementation could be:
if not self.endpoint.endswith('/v2'):
  self.endpoint = '/'.join([self.endpoint, 'v2'])

description: updated
Changed in python-openstackclient:
assignee: nobody → Imtiaz Chowdhury (chowdhury-imtiaz)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-openstackclient (master)

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

Changed in python-openstackclient:
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-openstackclient (master)

Reviewed: https://review.openstack.org/415301
Committed: https://git.openstack.org/cgit/openstack/python-openstackclient/commit/?id=1bd2bf67dab86bce06da89db65f2b532edf8e35e
Submitter: Jenkins
Branch: master

commit 1bd2bf67dab86bce06da89db65f2b532edf8e35e
Author: Imtiaz Chowdhury <email address hidden>
Date: Tue Dec 27 14:04:29 2016 -0800

    Fixes image api URL endpoint for certain scenario

    openstackclient fails to get image list when the image api endpoint
    has 'v2' substring in the URL. Instead of checking whether the api
    endpoint URL terminates with '/v2', the current logic is checking
    whether 'v2' appears anywhere in the endpoint string.

    This issue was discovered on a production setup where certain
    server names had 'v2' in their names. For example, when a hostname
    is gopher.dev20.com, the image list APIs fail.

    This commit updates the unit test to reflect this scenario. Without
    the change in openstackclient/api/image_v2.py, all the unit tests
    fail.

    Co-Authored-By: <email address hidden>
    Change-Id: I26b85afd646938272dbabe8e045b337b7df58c7d
    Closes-Bug: 1652827

Changed in python-openstackclient:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/python-openstackclient 3.7.0

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