Scripts requesting v3 get multiple choices with bad URLs
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/
This actually will work with anything after /, e.g., http://<nova-ip>:8774/asd
{"choices": [{"status": "SUPPORTED", "media-types": [{"base": "application/json", "type": "application/
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(
print(
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/
E.g., http://
Actual result
=============
As described above
Environment
===========
1. Version: 3f217a441af6595
2. Which hypervisor did you use?
Unrelated
2. Which storage type did you use?
Unrelated
3. Which networking type did you use?
Unrelated
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 . 21T11:33: 21Z", 127.0.0. 1:8774/ v2/", min_version" : "", 23T11:33: 21Z", 127.0.0. 1:8774/ v2.1/", min_version" : "2.1",
{
"versions": [
{
"status": "SUPPORTED",
"updated": "2011-01-
"links": [
{
"href": "http://
"rel": "self"
}
],
"
"version": "",
"id": "v2.0"
},
{
"status": "CURRENT",
"updated": "2013-07-
"links": [
{
"href": "http://
"rel": "self"
}
],
"
"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 . media-types" : [ vnd.openstack. compute+ json;version= 2" 127.0.0. 1:8774/ v2/stuff", media-types" : [ vnd.openstack. compute+ json;version= 2.1" 127.0.0. 1:8774/ v2.1/stuff",
{
"choices": [
{
"status": "SUPPORTED",
"
{
"base": "application/json",
"type": "application/
}
],
"id": "v2.0",
"links": [
{
"href": "http://
"rel": "self"
}
]
},
{
"status": "CURRENT",
"
{
"base": "application/json",
"type": "application/
}
],
"id": "v2.1",
"links": [
{
"href": "http://
"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?