The nova API service can't hand image metadata properly when metadata key contains uppercase letter

Bug #1352193 reported by Xiangjun Li
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance
In Progress
Medium
Artur Malinowski
OpenStack Compute (nova)
Won't Fix
Low
Unassigned

Bug Description

OS: centos 6.5 64bit
openstack release: icehouse

Steps to reproduce:
1. Call the image metadata API of nova using the following command:
 curl -X 'POST' -v http://IP:PORT/v2/${tenant_id}/images/${image_id}/metadata -H "X-Auth-Token: $token" -H 'Content-type: application/json' -d '{"metadata":{"Key1":"Value1"}}' | python -mjson.tool
2. Execute the above command again:
  curl -X 'POST' -v http://IP:PORT/v2/${tenant_id}/images/${image_id}/metadata -H "X-Auth-Token: $token" -H 'Content-type: application/json' -d '{"metadata":{"Key1":"Value1"}}' | python -mjson.tool

Expected result:
In step1, the json response should be:
  {"metadata":{"Key1":"Value1"}}
In setp2, the json response should be:
 {"metadata":{"Key1":"Value1"}}

Observed result:
In step1, the json response is:
  {"metadata":{"key1":"Value1"}}
In setp2, the json response is:
 {"metadata":{"key1":"Value1,Value1"}}

Besides, we can observer that each image metadata key in table image_properties of glance DB is converted to lowercase even if the key user inputted contains uppercase letter.

Tags: api
lvdongbing (dbcocle)
Changed in nova:
assignee: nobody → lvdongbing (dbcocle)
Tracy Jones (tjones-i)
tags: added: api
Revision history for this message
Sean Dague (sdague) wrote :

No patch in 30 days

Changed in nova:
status: New → Confirmed
assignee: lvdongbing (dbcocle) → nobody
importance: Undecided → Medium
Revision history for this message
jichenjc (jichenjc) wrote :

from following result

jichen@cloudcontroller:~$ glance image-update --property Key1=Value2 --purge-props 64f067bd-ce03-4f04-a354-7188a4828e8e
+------------------+--------------------------------------+
| Property | Value |
+------------------+--------------------------------------+
| Property 'key1' | Value2 |

I think we need to confirm with glance whether they only accept lower case key/value pair
if that's the case, nova should be updated in order to fit for that restriction

affects: nova → glance
Changed in nova:
status: New → Confirmed
assignee: nobody → jichenjc (jichenjc)
Revision history for this message
jichenjc (jichenjc) wrote :

https://github.com/openstack/glance/blob/master/glance/common/utils.py#L236

is glance's current behavior
nova should update its code according to glance

Revision history for this message
Eddie Sheffield (eddie-sheffield) wrote :

Seems like something which should change in Glance as well. I can see why it's it's lowercasing the key - to do a case-insensitive check on the prefix. But I don't believe it should be using the lowercased version to get the actual key.

Changed in glance:
assignee: nobody → Artur Malinowski (artur-malinowski)
status: Confirmed → In Progress
Revision history for this message
Dong Liu (liudong78) wrote :

I think this can only be fixed by using glance v2 api.

Revision history for this message
jichenjc (jichenjc) wrote :

ok, so any forecast?
wait for glance's update to make changes on nova side , thanks

summary: - The nova API service can’t hand image metadata properly when metadata
+ The nova API service can't hand image metadata properly when metadata
key contains uppercase letter
jichenjc (jichenjc)
Changed in nova:
importance: Undecided → Low
Changed in nova:
assignee: jichenjc (jichenjc) → nobody
Revision history for this message
Sean Dague (sdague) wrote :

The glance v1 API which the Nova images proxy is based on put metadata via headers. That means they are case insensitive. Nova will continue to do this regardless of backend, which means when talking to a v2 server, your metadata might be wrong.

The Nova image proxy should not be used, and Glance should be interacted with directly.

Changed in nova:
status: Confirmed → Won't Fix
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.