provisioning failed if the image have a non-ascii property and using qpid
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Glance Client |
Fix Released
|
Medium
|
Zhi Yan Liu | ||
OpenStack Compute (nova) |
Fix Released
|
Medium
|
Zhi Yan Liu |
Bug Description
If user set a non-ascii character to the key of an image property and using qpid backend, the instance provisioning will be failed.
Use case:
1. Set a non-ascii character to the key of an image property:
"glance image-update --property '中文'='中文' 5a7e6de5-
2. Launch a instance with that image:
"nova boot --image cirros-0.3.0-x86_64 --flavor m1.tiny --nic net-id=
3. Then the provisioning failed and nova-api service catch the exception and write to log:
File "/usr/lib/
self.send(snd, msg)
File "/usr/lib/
body = enc(msg.content)
File "/usr/lib/
sc.
File "/usr/lib/
getattr(self, "write_%s" % type.NAME)(v)
File "/usr/lib/
sc.
File "/usr/lib/
sc.
File "/usr/lib/
getattr(self, "write_%s" % type.NAME)(v)
File "/usr/lib/
sc.
File "/usr/lib/
sc.
File "/usr/lib/
getattr(self, "write_%s" % type.NAME)(v)
File "/usr/lib/
sc.
File "/usr/lib/
sc.
File "/usr/lib/
getattr(self, "write_%s" % type.NAME)(v)
File "/usr/lib/
sc.
File "/usr/lib/
sc.
File "/usr/lib/
getattr(self, "write_%s" % type.NAME)(v)
File "/usr/lib/
sc.
File "/usr/lib/
sc.
File "/usr/lib/
self.
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 0: ordinal not in range(128)
Analysis:
In nova-api service, the provisioning request will be handled in "nova/compute/
Solution:
There are two choices to resolve this issue:
1. Resolve in glanceclient. glance-api server return utf-8 property (key/value pair) to glanceclient, so we need convert the them back to unicode from utf-8 ("_image_
And this fix also need change 2 points in nova-api code ("nova/
2. Resolve in nova-api. This way probably is not good then above one since the area affected is greater the it. in this way, we need convert utf-8 string to unicode then to put it into queue, so the change/fix in "to_primitive" method of "jsonutils.py" file. for now, there are two problems:
a. it not take care key within a dict object, that caused utf-8 encoded key string (in this case, it's a key of an image property) will not be primitive.
b. need ask to_primitive take care utf-8 string, IMO, need convert it to unicode but not pass the utf-8 (basestring object) directly. So this fix will affect more area then above glanceclient fixing way, this fix has commonality, even user use rabbitmq backend, any utf-8 encoded key within a dict will be convert include glance properties and any other dict objects which want to primitive and put into queue.
IMO, I prefer use #1 way to address this issue.
Changed in glance: | |
assignee: | nobody → Zhi Yan Liu (lzy-dev) |
status: | New → In Progress |
affects: | glance → python-glanceclient |
tags: | added: grizzly-backport-potential |
Changed in nova: | |
milestone: | none → havana-2 |
status: | Fix Committed → Fix Released |
Changed in nova: | |
milestone: | havana-2 → 2013.2 |
tags: | removed: grizzly-backport-potential |
Changed in python-glanceclient: | |
status: | Fix Committed → Fix Released |
Addressed here: https:/ /review. openstack. org/#/c/ 29245/