encoding error when doing console-log

Bug #1746534 reported by Thomas Goirand
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-novaclient
Fix Released
High
Thomas Goirand

Bug Description

Testing Pike in Sid outputs the below result when doing "nova --debug console-log <UUID>":

DEBUG (session:722) POST call to compute for http://84.16.73.248:8774/v2.1/servers/92847293-3b4d-44cc-8cdd-6cb57e23b0cf/action used request id req-70870d58-a4a0-493b-abd8-f2289775035c
DEBUG (shell:951) '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/novaclient/shell.py", line 949, in main
    OpenStackComputeShell().main(argv)
  File "/usr/lib/python2.7/dist-packages/novaclient/shell.py", line 871, in main
    args.func(self.cs, args)
  File "/usr/lib/python2.7/dist-packages/novaclient/v2/shell.py", line 2558, in do_console_log
    print(data)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 22096-22098: ordinal not in range(128)
ERROR (UnicodeEncodeError): 'ascii' codec can't encode characters in position 22096-22098: ordinal not in range(128)

Same thing with openstack 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)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-novaclient (master)

Fix proposed to branch: master
Review: https://review.openstack.org/541610

Changed in python-novaclient:
assignee: nobody → Thomas Goirand (thomas-goirand)
status: New → In Progress
Revision history for this message
Thomas Goirand (thomas-goirand) wrote :

FYI, I opened a separate bug for python-openstackclient:

https://bugs.launchpad.net/python-openstackclient/+bug/1747862

and fixed both... :P

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-novaclient (master)

Reviewed: https://review.openstack.org/541610
Committed: https://git.openstack.org/cgit/openstack/python-novaclient/commit/?id=d272d6f3df2610a62f81e2ca26798ea8a6674b06
Submitter: Zuul
Branch: master

commit d272d6f3df2610a62f81e2ca26798ea8a6674b06
Author: Thomas Goirand <email address hidden>
Date: Wed Feb 7 09:17:12 2018 +0100

    Fix crashing console-log

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

    This patch sets the encoding output of stdout to utf8 before attempting
    to print in it.

    Change-Id: I63bc3dc8807021f5a97f58b0fe13a10d93688c7e
    Closes-Bug: 1746534

Changed in python-novaclient:
status: In Progress → Fix Released
Revision history for this message
melanie witt (melwitt) wrote :

Thomas, that means this one patch fixes the issue in both python-novaclient and python-openstackclient, correct? I'm going to mark the other bug as a duplicate of this one.

Changed in python-novaclient:
importance: Undecided → High
Revision history for this message
Thomas Goirand (thomas-goirand) wrote :

Melanie,

It does not, we have 2 separated bugs and 2 fixes, even the issues are the same, there is really 2 places to fix, and I have opened 2 patch reviews.

Revision history for this message
melanie witt (melwitt) wrote :

Sorry, I misunderstood what you meant in comment 2. I have un-duplicated the openstackclient bug and added a link to your patch.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/python-novaclient 10.2.0

This issue was fixed in the openstack/python-novaclient 10.2.0 release.

Revision history for this message
Matt Riedemann (mriedem) wrote :

Note that the fix was reverted: https://review.openstack.org/#/c/650235/

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to python-novaclient (master)

Related fix proposed to branch: master
Review: https://review.openstack.org/651827

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to python-novaclient (master)

Reviewed: https://review.openstack.org/651827
Committed: https://git.openstack.org/cgit/openstack/python-novaclient/commit/?id=e8f7aaf9091330bbb046f2bd42dc9c92f1dcebaa
Submitter: Zuul
Branch: master

commit e8f7aaf9091330bbb046f2bd42dc9c92f1dcebaa
Author: Matt Riedemann <email address hidden>
Date: Thu Apr 11 12:03:30 2019 -0400

    Add test for console-log and docs for bug 1746534

    We had no unit test coverage for the console-log command
    so this adds a simple test. It unfortunately does not
    recreate the original UnicodeEncodeError bug though, but
    it gives us some test coverage anyway.

    This change also adds docs on how to resolve bug 1746534
    by configuring the environment for UTF-8 as noted in
    the revert change Iaeec1e74262a35f3de3c81f7013835a6aa6f9029.

    The documentation added here is shamelessly copied from
    Click [1] which was found via the PEP 538 docs [2].

    [1] https://click.palletsprojects.com/en/5.x/python3/#python-3-surrogate-handling
    [2] https://www.python.org/dev/peps/pep-0538/

    Change-Id: Ic7059260dfc031ea1b08d2b8a7cec684bbe7dfa5
    Related-Bug: #1823287
    Related-Bug: #1746534

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to python-novaclient (stable/stein)

Related fix proposed to branch: stable/stein
Review: https://review.openstack.org/651925

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to python-novaclient (stable/rocky)

Related fix proposed to branch: stable/rocky
Review: https://review.openstack.org/652033

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to python-novaclient (stable/stein)

Reviewed: https://review.openstack.org/651925
Committed: https://git.openstack.org/cgit/openstack/python-novaclient/commit/?id=60bf9a236dfbaa98e7d93b4baf0997e645b02bb0
Submitter: Zuul
Branch: stable/stein

commit 60bf9a236dfbaa98e7d93b4baf0997e645b02bb0
Author: Matt Riedemann <email address hidden>
Date: Thu Apr 11 12:03:30 2019 -0400

    Add test for console-log and docs for bug 1746534

    We had no unit test coverage for the console-log command
    so this adds a simple test. It unfortunately does not
    recreate the original UnicodeEncodeError bug though, but
    it gives us some test coverage anyway.

    This change also adds docs on how to resolve bug 1746534
    by configuring the environment for UTF-8 as noted in
    the revert change Iaeec1e74262a35f3de3c81f7013835a6aa6f9029.

    The documentation added here is shamelessly copied from
    Click [1] which was found via the PEP 538 docs [2].

    [1] https://click.palletsprojects.com/en/5.x/python3/#python-3-surrogate-handling
    [2] https://www.python.org/dev/peps/pep-0538/

    Change-Id: Ic7059260dfc031ea1b08d2b8a7cec684bbe7dfa5
    Related-Bug: #1823287
    Related-Bug: #1746534
    (cherry picked from commit e8f7aaf9091330bbb046f2bd42dc9c92f1dcebaa)

tags: added: in-stable-stein
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to python-novaclient (stable/rocky)

Reviewed: https://review.openstack.org/652033
Committed: https://git.openstack.org/cgit/openstack/python-novaclient/commit/?id=efdbac35b0c00ca39b986b7fb58515e2b5059384
Submitter: Zuul
Branch: stable/rocky

commit efdbac35b0c00ca39b986b7fb58515e2b5059384
Author: Matt Riedemann <email address hidden>
Date: Thu Apr 11 12:03:30 2019 -0400

    Add test for console-log and docs for bug 1746534

    We had no unit test coverage for the console-log command
    so this adds a simple test. It unfortunately does not
    recreate the original UnicodeEncodeError bug though, but
    it gives us some test coverage anyway.

    This change also adds docs on how to resolve bug 1746534
    by configuring the environment for UTF-8 as noted in
    the revert change Iaeec1e74262a35f3de3c81f7013835a6aa6f9029.

    The documentation added here is shamelessly copied from
    Click [1] which was found via the PEP 538 docs [2].

    [1] https://click.palletsprojects.com/en/5.x/python3/#python-3-surrogate-handling
    [2] https://www.python.org/dev/peps/pep-0538/

    Change-Id: Ic7059260dfc031ea1b08d2b8a7cec684bbe7dfa5
    Related-Bug: #1823287
    Related-Bug: #1746534
    (cherry picked from commit e8f7aaf9091330bbb046f2bd42dc9c92f1dcebaa)
    (cherry picked from commit 60bf9a236dfbaa98e7d93b4baf0997e645b02bb0)

tags: added: in-stable-rocky
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.