[zaqarclient] version argument to client can produce errors when passing a float value

Bug #1572616 reported by Michael McCune
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Python client library for Zaqar
Fix Released
Undecided
wangxiyuan

Bug Description

i am creating an application that uses an oslo.config value to enable the user with the ability to choose their zaqar version. one way to do this is to use a FloatOpt for the config value to allow values such as "1.1". in the course of doing this work, i have learned that when passing a value of "2" as a float to the zaqarclient.queues.client.Client object, that value is actually received as "2.0". this inconsistency causes an issue based around the mixed type keys that are present in the version mapping internal to the client api dynamically loading the impl[1].

steps to reproduce (from the python repl):

>>> from zaqarclient.queues import client as zaqar_client
>>> zc = zaqar_client.Client('http://10.0.1.108:8888/', 1.1, zconf)
>>> zc.queues()
<zaqarclient.queues.v1.iterator._Iterator object at 0x7ff28efc8f10>
>>> zc = zaqar_client.Client('http://10.0.1.108:8888/', 2.0, zconf)
>>> zc.queues()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/mike/.venvs/openstack/lib/python2.7/site-packages/zaqarclient/queues/v1/client.py", line 111, in queues
    queue_list = core.queue_list(trans, req, **params)
  File "/home/mike/.venvs/openstack/lib/python2.7/site-packages/zaqarclient/queues/v1/core.py", line 171, in queue_list
    resp = transport.send(request)
  File "/home/mike/.venvs/openstack/lib/python2.7/site-packages/zaqarclient/transport/http.py", line 86, in send
    url, method, request = self._prepare(request)
  File "/home/mike/.venvs/openstack/lib/python2.7/site-packages/zaqarclient/transport/http.py", line 45, in _prepare
    if not request.api:
  File "/home/mike/.venvs/openstack/lib/python2.7/site-packages/zaqarclient/transport/request.py", line 115, in api
    raise errors.DriverLoadFailure(self._api_mod, ex)
zaqarclient.errors.DriverLoadFailure: Failed to load transport driver "queues.v2.0": No 'zaqarclient.api' driver found, looking for 'queues.v2.0'

suggested fix:

the Client object should be more tolerant of values that it accepts and convert them to the proper value, especially if this value will be used to template rest calls.

[1]: https://github.com/openstack/python-zaqarclient/blob/master/zaqarclient/transport/request.py#L110

Tags: zaqarclient
description: updated
description: updated
wangxiyuan (wangxiyuan)
Changed in zaqar:
assignee: nobody → wangxiyuan (wangxiyuan)
Revision history for this message
wangxiyuan (wangxiyuan) wrote :
Changed in zaqar:
status: New → In Progress
wangxiyuan (wangxiyuan)
affects: zaqar → python-zaqarclient
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-zaqarclient (master)

Reviewed: https://review.openstack.org/308736
Committed: https://git.openstack.org/cgit/openstack/python-zaqarclient/commit/?id=eeba0f3b8c68ff1fea6edbdb8e4c012e752636f2
Submitter: Jenkins
Branch: master

commit eeba0f3b8c68ff1fea6edbdb8e4c012e752636f2
Author: wangxiyuan <email address hidden>
Date: Thu Apr 21 12:15:24 2016 +0800

    Ensure the float value of api version could work

    Now if we pass a float value of api version such as "v1.0" or
    "v2.0", client will raise a DriverLoadFailure error. Because
    that client can't match a sutiable API entry.

    So we should ensure that that some value like "v1.0" could
    work as "v1".

    Change-Id: I9631a083fd96a535153b6029b95a1d3c8d9966a2
    Closes-bug: #1572616

Changed in python-zaqarclient:
status: In Progress → Fix Released
Revision history for this message
Doug Hellmann (doug-hellmann) wrote : Fix included in openstack/python-zaqarclient 1.1.0

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