Glance CLI was corrupted with unicode interaction

Bug #1574578 reported by Alexey Galkin
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mirantis OpenStack
Status tracked in 10.0.x
10.0.x
Fix Committed
High
Darja Shakhray

Bug Description

Detailed bug description:

 Glance CLI client return a 'UnicodeEncodeError' when creating an image with using unicode characters in name.

Steps to reproduce:

 1. Make ssh to controller.
 2. Use command:
       . openrc && env PYTHONIOENCODING=UTF-8 glance --debug --os-image-api-version 1 image-create --name 試験画像_1

Expected results:

 root@node-1:~# . openrc && env PYTHONIOENCODING=UTF-8 glance --debug --os-image-api-version 1 image-create --name 試験画像_1
+------------------+--------------------------------------+
| Property | Value |
+------------------+--------------------------------------+
| checksum | None |
| container_format | None |
| created_at | 2016-04-25T11:05:15.000000 |
| deleted | False |
| deleted_at | None |
| disk_format | None |
| id | b3da0f6e-a8dd-4124-b72e-4eabf7f6f4c2 |
| is_public | False |
| min_disk | 0 |
| min_ram | 0 |
| name | kek_1 |
| owner | eeb47d2783794ea583dc4790e4bd6459 |
| protected | False |
| size | 0 |
| status | queued |
| updated_at | 2016-04-25T11:05:15.000000 |
| virtual_size | None |
+------------------+--------------------------------------+

Actual result:
 root@node-1:~# glance --debug --os-image-api-version 1 image-create --name 試験画像_1
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/glanceclient/shell.py", line 595, in main
    args.func(client, args)
  File "/usr/lib/python2.7/dist-packages/glanceclient/common/utils.py", line 98, in func_wrapper
    return func(gc, args)
  File "/usr/lib/python2.7/dist-packages/glanceclient/v1/shell.py", line 258, in do_image_create
    image = gc.images.create(**fields)
  File "/usr/lib/python2.7/dist-packages/glanceclient/v1/images.py", line 324, in create
    data=image_data)
  File "/usr/lib/python2.7/dist-packages/keystoneclient/adapter.py", line 182, in post
    return self.request(url, 'POST', **kwargs)
  File "/usr/lib/python2.7/dist-packages/glanceclient/common/http.py", line 318, in request
    **kwargs)
  File "/usr/lib/python2.7/dist-packages/keystoneclient/adapter.py", line 101, in request
    return self.session.request(url, method, **kwargs)
  File "/usr/lib/python2.7/dist-packages/positional/__init__.py", line 94, in inner
    return func(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/keystoneclient/session.py", line 405, in request
    resp = send(**kwargs)
  File "/usr/lib/python2.7/dist-packages/keystoneclient/session.py", line 439, in _send_request
    resp = self.session.request(method, url, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 468, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 576, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 376, in send
    timeout=timeout
  File "/usr/lib/python2.7/dist-packages/urllib3/connectionpool.py", line 559, in urlopen
    body=body, headers=headers)
  File "/usr/lib/python2.7/dist-packages/urllib3/connectionpool.py", line 353, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python2.7/httplib.py", line 979, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python2.7/httplib.py", line 1012, in _send_request
    self.putheader(hdr, value)
  File "/usr/lib/python2.7/httplib.py", line 959, in putheader
    hdr = '%s: %s' % (header, '\r\n\t'.join([str(v) for v in values]))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)
'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)

Reproducibility:

 Only with using API v1 ( --os-image-api-version 1).

Workaround:

 Use v2 or Horizon to work with images.

Impact:

 -

Description of the environment:

 - Glance python client version:
      root@node-1:~# glance --version
       2.0.0
 - Shotgun2 report: http://paste.openstack.org/show/495287/
 - MOS/Fuel: mitaka-9.0-229

Additional information:

 Package version: python-glanceclient/mos9.0,now 1:2.0.0-1~u14.04+mos0 all [installed,automatic]

Revision history for this message
Darja Shakhray (dshakhray) wrote :
Revision history for this message
Darja Shakhray (dshakhray) wrote :
Changed in mos:
status: Confirmed → Fix Committed
Revision history for this message
Ilya Menkov (imenkov) wrote :

Fix works fine. It was validated on build 400.

Changed in mos:
status: Fix Committed → Fix Released
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.