encoding error when doing console log show

Bug #1747862 reported by Thomas Goirand
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-openstackclient
Fix Released
Undecided
Unassigned

Bug Description

Testing Pike in Sid outputs the below result when doing "openstack --debug console log show 92847293-3b4d-44cc-8cdd-6cb57e23b0cf":

POST call to compute for http://84.16.73.248:8774/v2.1/servers/92847293-3b4d-44cc-8cdd-6cb57e23b0cf/action used request id req-6670b673-b113-4fbf-a362-5c477e47d05c
'ascii' codec can't encode characters in position 22096-22098: ordinal not in range(128)
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/cliff/app.py", line 400, in run_subcommand
    result = cmd.run(parsed_args)
  File "/usr/lib/python2.7/dist-packages/osc_lib/command/command.py", line 41, in run
    return super(Command, self).run(parsed_args)
  File "/usr/lib/python2.7/dist-packages/cliff/command.py", line 137, in run
    return_code = self.take_action(parsed_args) or 0
  File "/usr/lib/python2.7/dist-packages/openstackclient/compute/v2/console.py", line 63, in take_action
    sys.stdout.write(data)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 22096-22098: ordinal not in range(128)
clean_up ShowConsoleLog: 'ascii' codec can't encode characters in position 22096-22098: ordinal not in range(128)
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/osc_lib/shell.py", line 134, in run
    ret_val = super(OpenStackShell, self).run(argv)
  File "/usr/lib/python2.7/dist-packages/cliff/app.py", line 279, in run
    result = self.run_subcommand(remainder)
  File "/usr/lib/python2.7/dist-packages/osc_lib/shell.py", line 169, in run_subcommand
    ret_value = super(OpenStackShell, self).run_subcommand(argv)
  File "/usr/lib/python2.7/dist-packages/cliff/app.py", line 400, in run_subcommand
    result = cmd.run(parsed_args)
  File "/usr/lib/python2.7/dist-packages/osc_lib/command/command.py", line 41, in run
    return super(Command, self).run(parsed_args)
  File "/usr/lib/python2.7/dist-packages/cliff/command.py", line 137, in run
    return_code = self.take_action(parsed_args) or 0
  File "/usr/lib/python2.7/dist-packages/openstackclient/compute/v2/console.py", line 63, in take_action
    sys.stdout.write(data)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 22096-22098: ordinal not in range(128)

IMO, the issue is that we should be setting the console to output utf8 with something like this:

sys.stdout = codecs.getwriter('utf8')(sys.stdout)

which is what I'm going to do as a patch proposal right away...

Revision history for this message
Thomas Goirand (thomas-goirand) wrote :

nova-console has the same type of problem which I reported separately:

https://bugs.launchpad.net/python-novaclient/+bug/1746534

Revision history for this message
melanie witt (melwitt) wrote :
Changed in python-openstackclient:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-openstackclient (master)

Reviewed: https://review.openstack.org/541609
Committed: https://git.openstack.org/cgit/openstack/python-openstackclient/commit/?id=9a173568548203757a7fd20883edd56f923cc7e8
Submitter: Zuul
Branch: master

commit 9a173568548203757a7fd20883edd56f923cc7e8
Author: Thomas Goirand <email address hidden>
Date: Wed Feb 7 09:25:33 2018 +0100

    Fix crashing "console log show"

    Because of encoding issue, the "openstack console show log" is prone to
    a stack dump, as explained in the bug report.

    Use the stdout handle that has already been set up by cliff's App class
    with a sane default encoding.

    Change-Id: I4d8b0df7f16ee0463e638bb11276220e5b92023b
    Closes-Bug: 1747862

Changed in python-openstackclient:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/python-openstackclient 3.15.0

This issue was fixed in the openstack/python-openstackclient 3.15.0 release.

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.