A cached schema breaks 'fall back to v1' logic

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

Bug Description

Fallback to v1 doesn't work if the schema has been cached previously.

Pointing a client at a v1 only server, when no api version has been specified, should result in falling back to a v1 call.
If the schema has been cached this doesn't happen:

$ glance --os-tenant-name=blah --os-username=blah --os-auth-url=blah --os-region region-blah image-show d6bc96f0-70da-432b-a27c-dcf99d61ef0d
HTTPMultipleChoices (HTTP 300) Requested version of OpenStack Images API is not available.

Removing the schema from ~/.glanceclient gives the expected behaviour:

$ glance --os-tenant-name=blah --os-username=blah --os-auth-url=blah --os-region region-blah image-show d6bc96f0-70da-432b-a27c-dcf99d61ef0d
WARNING: The client is falling back to v1 because the accessing to v2 failed. This behavior will be removed in future versions
+------------------+--------------------------------------+
| Property | Value |
+------------------+--------------------------------------+
| checksum | a16a81de3d944ebee63810f36b826a63 |
| container_format | bare |
| created_at | 2014-07-31T12:48:53 |
| deleted | False |
| disk_format | raw |
| id | d6bc96f0-70da-432b-a27c-dcf99d61ef0d |
| is_public | False |
| min_disk | 0 |
| min_ram | 0 |
| name | x |
| owner | 61624292678963 |
| protected | False |
| size | 1048576000 |
| status | active |
| updated_at | 2014-07-31T12:49:47 |
+------------------+--------------------------------------+

tags: added: 1.0.0-potential
Revision history for this message
Flavio Percoco (flaper87) wrote :
Changed in python-glanceclient:
assignee: nobody → Flavio Percoco (flaper87)
importance: Undecided → Medium
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-glanceclient (master)

Reviewed: https://review.openstack.org/219469
Committed: https://git.openstack.org/cgit/openstack/python-glanceclient/commit/?id=47423ebbb2dfcb0d63aefcb87a9bec85420a7a99
Submitter: Jenkins
Branch: master

commit 47423ebbb2dfcb0d63aefcb87a9bec85420a7a99
Author: Flavio Percoco <email address hidden>
Date: Tue Sep 1 23:28:11 2015 +0200

    Check if v2 is available and fallback

    We have a basic implementation for a fallback mechanism that will use v1
    rather than v2 when downloading schema files from glance-api fails.
    However, this is not sound. If the schemas are cached already, we won't
    check if v2 is available and fail to fallback.

    This patch fixes the aforementioned issue by getting the list of
    available versions from the server only when the API versions was not
    explicitly specified through the CLI. That is, for all commands that
    don't pass `--os-image-api-version 2`, we'll check v2's availability and
    we'll fallback to v1 if it isn't available.

    This patch also changes how we handle `/versions` calls in the client.
    The server has been, incorrectly, replying to requests to `/version`
    with a 300 error, which ended up in the client re-raising such
    exception. While I think 300 shouldn't raise an exception, I think we
    should handle that in a spearate patch. Therefore, this patch just
    avoids raising such exception when `/version` is explicitly called.

    This fallback behaviour and the check on `/versions` will be removed in
    future versions of the client. The later depends on this bug[0] being
    fixed.

    [0] https://bugs.launchpad.net/glance/+bug/1491350

    Closes-bug: #1489381
    Change-Id: Ibeba6bc86db2a97b8a2b4bd042248464cd792e5e

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