libvirt: resume instance with utf-8 name results in UnicodeDecodeError

Bug #1453274 reported by Taylor Peoples
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
Taylor Peoples
Juno
Fix Released
Undecided
Taylor Peoples
Kilo
Fix Released
Undecided
Taylor Peoples

Bug Description

This bug is very similar to https://bugs.launchpad.net/nova/+bug/1388386.

Resuming a server that has a unicode name after suspending it results in:

2015-05-08 15:22:30.148 4370 INFO nova.compute.manager [req-ac919325-aa2d-422c-b679-5f05ecca5d42 0688b01e6439ca32d698d20789d52169126fb41fb1a4ddafcebb97d854e836c9 6dfced8dd0df4d4d98e4a0db60526c8d - - -] [instance: 12371aa8-889d-4333-8fab-61a13f87a547] Resuming
2015-05-08 15:22:31.651 4370 ERROR nova.compute.manager [req-ac919325-aa2d-422c-b679-5f05ecca5d42 0688b01e6439ca32d698d20789d52169126fb41fb1a4ddafcebb97d854e836c9 6dfced8dd0df4d4d98e4a0db60526c8d - - -] [instance: 12371aa8-889d-4333-8fab-61a13f87a547] Setting instance vm_state to ERROR
2015-05-08 15:22:31.651 4370 TRACE nova.compute.manager [instance: 12371aa8-889d-4333-8fab-61a13f87a547] Traceback (most recent call last):
2015-05-08 15:22:31.651 4370 TRACE nova.compute.manager [instance: 12371aa8-889d-4333-8fab-61a13f87a547] File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 6427, in _error_out_instance_on_exception
2015-05-08 15:22:31.651 4370 TRACE nova.compute.manager [instance: 12371aa8-889d-4333-8fab-61a13f87a547] yield
2015-05-08 15:22:31.651 4370 TRACE nova.compute.manager [instance: 12371aa8-889d-4333-8fab-61a13f87a547] File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 4371, in resume_instance
2015-05-08 15:22:31.651 4370 TRACE nova.compute.manager [instance: 12371aa8-889d-4333-8fab-61a13f87a547] block_device_info)
2015-05-08 15:22:31.651 4370 TRACE nova.compute.manager [instance: 12371aa8-889d-4333-8fab-61a13f87a547] File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py", line 2234, in resume
2015-05-08 15:22:31.651 4370 TRACE nova.compute.manager [instance: 12371aa8-889d-4333-8fab-61a13f87a547] vifs_already_plugged=True)
2015-05-08 15:22:31.651 4370 TRACE nova.compute.manager [instance: 12371aa8-889d-4333-8fab-61a13f87a547] File "/usr/lib/python2.7/site-packages/powervc_nova/virt/powerkvm/driver.py", line 2061, in _create_domain_and_network
2015-05-08 15:22:31.651 4370 TRACE nova.compute.manager [instance: 12371aa8-889d-4333-8fab-61a13f87a547] disk_info=disk_info)
2015-05-08 15:22:31.651 4370 TRACE nova.compute.manager [instance: 12371aa8-889d-4333-8fab-61a13f87a547] File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py", line 4391, in _create_domain_and_network
2015-05-08 15:22:31.651 4370 TRACE nova.compute.manager [instance: 12371aa8-889d-4333-8fab-61a13f87a547] power_on=power_on)
2015-05-08 15:22:31.651 4370 TRACE nova.compute.manager [instance: 12371aa8-889d-4333-8fab-61a13f87a547] File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py", line 4322, in _create_domain
2015-05-08 15:22:31.651 4370 TRACE nova.compute.manager [instance: 12371aa8-889d-4333-8fab-61a13f87a547] LOG.error(err)
2015-05-08 15:22:31.651 4370 TRACE nova.compute.manager [instance: 12371aa8-889d-4333-8fab-61a13f87a547] File "/usr/lib/python2.7/site-packages/oslo_utils/excutils.py", line 85, in __exit__
2015-05-08 15:22:31.651 4370 TRACE nova.compute.manager [instance: 12371aa8-889d-4333-8fab-61a13f87a547] six.reraise(self.type_, self.value, self.tb)
2015-05-08 15:22:31.651 4370 TRACE nova.compute.manager [instance: 12371aa8-889d-4333-8fab-61a13f87a547] File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py", line 4305, in _create_domain
2015-05-08 15:22:31.651 4370 TRACE nova.compute.manager [instance: 12371aa8-889d-4333-8fab-61a13f87a547] err = _LE('Error defining a domain with XML: %s') % xml
2015-05-08 15:22:31.651 4370 TRACE nova.compute.manager [instance: 12371aa8-889d-4333-8fab-61a13f87a547] UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 297: ordinal not in range(128)
2015-05-08 15:22:31.651 4370 TRACE nova.compute.manager [instance: 12371aa8-889d-4333-8fab-61a13f87a547]

The _create_domain() method has the following line:

err = _LE('Error defining a domain with XML: %s') % xml

which fails with the UnicodeDecodeError because the xml object has utf-8 encoding. The fix is to wrap the xml object in oslo.utils.encodeutils.safe_decode for the error message.

I'm seeing the issue on Kilo, but it is also likely an issue on Juno as well.

Changed in nova:
assignee: nobody → Taylor Peoples (tpeoples)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

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

Changed in nova:
status: New → In Progress
Jay Pipes (jaypipes)
Changed in nova:
importance: Undecided → Medium
tags: added: juno-backport-potential kilo-backport-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/181708
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=96a2283c1a07f0298c57f57d8c4112c1c33b6128
Submitter: Jenkins
Branch: master

commit 96a2283c1a07f0298c57f57d8c4112c1c33b6128
Author: Taylor Peoples <email address hidden>
Date: Sun May 10 06:23:26 2015 +0200

    libvirt: safe_decode xml for i18n logging

    The xml argument passed to _create_domain can be a utf-8 encoded string
    which causes a UnicodeDecodeError when it is substituted into the _LE
    unicode translated message. Safely decoding the xml argument before
    attempting to substitute it into the error message avoids the
    UnicodeDecodeError.

    Closes-Bug: #1453274
    Change-Id: I4cf1836f4ca9097f7c6d98c5212a14d24111fe67

Changed in nova:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (stable/juno)

Fix proposed to branch: stable/juno
Review: https://review.openstack.org/182536

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (stable/kilo)

Fix proposed to branch: stable/kilo
Review: https://review.openstack.org/182539

Matt Riedemann (mriedem)
tags: removed: juno-backport-potential kilo-backport-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (stable/kilo)

Reviewed: https://review.openstack.org/182539
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=c66c8e172ed00d67c3172572aa60c3ece83beeea
Submitter: Jenkins
Branch: stable/kilo

commit c66c8e172ed00d67c3172572aa60c3ece83beeea
Author: Taylor Peoples <email address hidden>
Date: Sun May 10 06:23:26 2015 +0200

    libvirt: safe_decode xml for i18n logging

    The xml argument passed to _create_domain can be a utf-8 encoded string
    which causes a UnicodeDecodeError when it is substituted into the _LE
    unicode translated message. Safely decoding the xml argument before
    attempting to substitute it into the error message avoids the
    UnicodeDecodeError.

    (cherry picked from commit 96a2283c1a07f0298c57f57d8c4112c1c33b6128)

    Conflicts:

     nova/virt/libvirt/driver.py

    Closes-Bug: #1453274
    Change-Id: I4cf1836f4ca9097f7c6d98c5212a14d24111fe67

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (stable/juno)

Reviewed: https://review.openstack.org/182536
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=8f13587ba50622126d6f8b6622273206e33f9f5b
Submitter: Jenkins
Branch: stable/juno

commit 8f13587ba50622126d6f8b6622273206e33f9f5b
Author: Taylor Peoples <email address hidden>
Date: Sun May 10 06:23:26 2015 +0200

    libvirt: safe_decode xml for i18n logging

    The xml argument passed to _create_domain can be a utf-8 encoded string
    which causes a UnicodeDecodeError when it is substituted into the _LE
    unicode translated message. Safely decoding the xml argument before
    attempting to substitute it into the error message avoids the
    UnicodeDecodeError.

    (cherry picked from commit 96a2283c1a07f0298c57f57d8c4112c1c33b6128)

    Conflicts:

     nova/tests/unit/virt/libvirt/test_driver.py
     nova/virt/libvirt/driver.py

    Change to strutils (instead of encodeutils) and test is located in
    "tests/" instead of "tests/unit/".

    Closes-Bug: #1453274
    Change-Id: I4cf1836f4ca9097f7c6d98c5212a14d24111fe67

Thierry Carrez (ttx)
Changed in nova:
milestone: none → liberty-1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: liberty-1 → 12.0.0
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.