Scripts requesting v3 get multiple choices with bad URLs

Bug #1567621 reported by Ian Cordasco
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Triaged
Medium
Unassigned

Bug Description

Description
===========

We have an old script which was requesting http://<nova-ip>:8774/v3 and received a 300 multiple choices, the response body looks like this though:

{"choices": [{"status": "SUPPORTED", "media-types": [{"base": "application/json", "type": "application/vnd.openstack.compute+json;version=2"}], "id": "v2.0", "l│inks": [{"href": "http://127.0.0.1:8774/v2/v3", "rel": "self"}]}, {"status": "CURRENT", "media-types": [{"base": "application/json", "type": "application/vnd.op│enstack.compute+json;version=2.1"}], "id": "v2.1", "links": [{"href": "http://127.0.0.1:8774/v2.1/v3", "rel": "self"}]}]}

This actually will work with anything after /, e.g., http://<nova-ip>:8774/asd

{"choices": [{"status": "SUPPORTED", "media-types": [{"base": "application/json", "type": "application/vnd.openstack.compute+json;version=2"}], "id": "v2.0", "l│inks": [{"href": "http://127.0.0.1:8774/v2/asd", "rel": "self"}]}, {"status": "CURRENT", "media-types": [{"base": "application/json", "type": "application/vnd.o│penstack.compute+json;version=2.1"}], "id": "v2.1", "links": [{"href": "http://127.0.0.1:8774/v2.1/asd", "rel": "self"}]}]}

Steps to reproduce
==================
A chronological list of steps which will bring off the
issue you noticed:
* I upgraded Kilo to Liberty
* then I made a request to http://<nova-ip>:8774/v3
* then I saw a response body like above

Example code:

    import requests

    r = requests.get('http://<nova-ip>:8774/v3')
    print(r.status_code)
    print(r.content)

Alternatively,

    curl -i http://<nova-ip>:8774/v3

Expected result
===============

I would have expected to see a response like:

{"choices": [{"status": "SUPPORTED", "media-types": [{"base": "application/json", "type": "application/vnd.openstack.compute+json;version=2"}], "id": "v2.0", "l│inks": [{"href": "http://127.0.0.1:8774/v2", "rel": "self"}]}, {"status": "CURRENT", "media-types": [{"base": "application/json", "type": "application/vnd.op│enstack.compute+json;version=2.1"}], "id": "v2.1", "links": [{"href": "http://127.0.0.1:8774/v2.1", "rel": "self"}]}]}

E.g., http://127.0.0.1:8774/v2.1 instead of http://127.0.0.1:8774/v2.1/v3

Actual result
=============

As described above

Environment
===========
1. Version: 3f217a441af6595cb2a240ab72133aff133504b6 (stable/liberty)

2. Which hypervisor did you use?
    Unrelated

2. Which storage type did you use?
    Unrelated

3. Which networking type did you use?
    Unrelated

tags: added: api
Revision history for this message
Fahri Cihan Demirci (cihand) wrote :

You get the expected result when you make a request to the versionless endpoint, like http://<nova-ip>:8774:

$ curl -s http://127.0.0.1:8774 | jq .
{
  "versions": [
    {
      "status": "SUPPORTED",
      "updated": "2011-01-21T11:33:21Z",
      "links": [
        {
          "href": "http://127.0.0.1:8774/v2/",
          "rel": "self"
        }
      ],
      "min_version": "",
      "version": "",
      "id": "v2.0"
    },
    {
      "status": "CURRENT",
      "updated": "2013-07-23T11:33:21Z",
      "links": [
        {
          "href": "http://127.0.0.1:8774/v2.1/",
          "rel": "self"
        }
      ],
      "min_version": "2.1",
      "version": "2.12",
      "id": "v2.1"
    }
  ]
}

When you make a request to a versioned endpoint which does not have a valid version then you get choices which contain the versioned endpoints suffixed with the version string you specified:

$ curl -s http://127.0.0.1:8774/stuff | jq .
{
  "choices": [
    {
      "status": "SUPPORTED",
      "media-types": [
        {
          "base": "application/json",
          "type": "application/vnd.openstack.compute+json;version=2"
        }
      ],
      "id": "v2.0",
      "links": [
        {
          "href": "http://127.0.0.1:8774/v2/stuff",
          "rel": "self"
        }
      ]
    },
    {
      "status": "CURRENT",
      "media-types": [
        {
          "base": "application/json",
          "type": "application/vnd.openstack.compute+json;version=2.1"
        }
      ],
      "id": "v2.1",
      "links": [
        {
          "href": "http://127.0.0.1:8774/v2.1/stuff",
          "rel": "self"
        }
      ]
    }
  ]
}

Since 3 is not a valid version, the choices you get are expected. For reference: http://developer.openstack.org/api-ref-compute-v2.1.html

Therefore, I think that this behaviour you are encountering is intentional and not a bug. Do you agree with my statements?

Revision history for this message
jichenjc (jichenjc) wrote :

yeah, v3 is not supported and the return data seems make sense

Sean Dague (sdague)
Changed in nova:
status: New → Confirmed
Revision history for this message
Sean Dague (sdague) wrote :

This is one of those really weird things about how the / versions API works. It attempts to imply that anything that you are fetching which isn't in the top root might be a real url but doesn't verify it

https://github.com/openstack/nova/blob/d761ba3bd4474fdca6740d6aed3331aa433a8b4a/nova/api/openstack/compute/versions.py#L89

I kind of thing the real answer here is to 404 on the random urls, as they don't really provide any real detail. Proposing a WIP patch that does that.

Changed in nova:
status: Confirmed → Triaged
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

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

Changed in nova:
assignee: nobody → Sean Dague (sdague)
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on nova (master)

Change abandoned by Michael Still (<email address hidden>) on branch: master
Review: https://review.openstack.org/307186
Reason: This code hasn't been updated in a long time, and is in merge conflict. I am going to abandon this review, but feel free to restore it if you're still working on this.

Revision history for this message
Sean Dague (sdague) wrote :

There are no currently open reviews on this bug, changing
the status back to the previous state and unassigning. If
there are active reviews related to this bug, please include
links in comments.

Changed in nova:
status: In Progress → Triaged
assignee: Sean Dague (sdague) → nobody
Revision history for this message
Sean Dague (sdague) wrote :

Automatically discovered version kilo in description. If this is incorrect, please update the description to include 'nova version: ...'

tags: added: openstack-version.kilo
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.