Glance JS API getImage() is inefficient

Bug #1559279 reported by Matt Borland
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Fix Released
Low
Matt Borland

Bug Description

The Glance API JS has a getImage() function that calls '/api/glance/images/' + id, with no trailing slash. When this hits the API, it is redirected via a 301 to '/api/glance/images/' + id + '/' (with a trailing slash). This adds a second network communication and thus increases latency.

If the API is just called with a trailing slash, the API responds directly with the result, which is a bit faster.

You can verify the bug and fix by watching the server in dev mode when going to the Angular Image Detail page. You will see a 301 call immediately followed by another call with the trailing slash. You can see this in the JavaScript window as well.

After applying the fix, you should no longer see the 301 result as there will be no call for the resource without the trailing slash.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to horizon (master)

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

Changed in horizon:
assignee: nobody → Matt Borland (palecrow)
status: New → In Progress
Changed in horizon:
importance: Undecided → Low
milestone: none → newton-1
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to horizon (master)

Reviewed: https://review.openstack.org/294789
Committed: https://git.openstack.org/cgit/openstack/horizon/commit/?id=2d6e0fb0b816ef3809ad0a8f6a15632a8511d38f
Submitter: Jenkins
Branch: master

commit 2d6e0fb0b816ef3809ad0a8f6a15632a8511d38f
Author: Matt Borland <email address hidden>
Date: Fri Mar 18 13:54:53 2016 -0600

    Fix bad/inefficient API call for JS getImage()

    The Angular API library for Glance has a function getImage(). This
    function currently calls to an API like:

    /api/glance/images/abasdfasdfas

    However, that returns a 301 and redirects to:

    /api/glance/images/abasdfasdfas/ <-- trailing slash

    This causes latency and unnecessary overhead.

    To test this fix, first verify the 301 problem before applying:

    Run Horizon in debug (watch the server responses)
    Enable the NG Images panel (enable _1051_ng_image...).
    Go to the NG Images panel, then as you click on a Details view,
    withess the 301 call with no trailing slash, followed by a
    successful call with a 200 and trailing slash.

    Then apply the patch.

    Then do the same, but notice how there is only one 200 call, with
    the trailing slash.

    Change-Id: I0f119e2568d41c4aa63176a8bf8f2fabfbed1b47
    Closes-Bug: 1559279

Changed in horizon:
status: In Progress → Fix Released
Revision history for this message
Davanum Srinivas (DIMS) (dims-v) wrote : Fix included in openstack/horizon 10.0.0.0b1

This issue was fixed in the openstack/horizon 10.0.0.0b1 development milestone.

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.