No response from rpc call when unicode in exception

Bug #1310397 reported by James Carey
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo.messaging
Medium
James Carey

Bug Description

When trying to test Nova with Korean or Chinese translations for the messages, the nova-compute process doesn't start up.

The reason this is occurring is that the libvirt driver is making a call-back to the database on the Mgmt System (via the conductor) to get the service/compute-node in order to try to update the service to enabled, and at the time they do it is before the Compute Manager has actually created the service & compute-node int he db, so in normal scenarios it throws a ComputeHostNotFound exception which just ends up as a message in the log file.

When the conductor messages are replaced with translations the exception message contains unicode characters.

The debug trace statement in the "ExpectedException" block in the _dispatch_and_reply method in the oslo/messaging/rpc/dispatcher.py module, gets a UnicodeEncodeError on the trace statement, with the error " 'ascii' codec can't encode characters in position 24-25: ordinal not in range(128)".... which causes the method to blow up and never send the reply. (If the trace statement is commented out then nova-compute starts).

The statement:

   LOG.debug('Expected exception during message handling (%s)' % e.exc_info[1])

is using unicode replacement text in a non-unicode string (py2x).

This log and at least the other one in the file need to handle unicode in exceptions.

James Carey (jecarey)
Changed in oslo.messaging:
assignee: nobody → James Carey (jecarey)
Revision history for this message
Openstack Gerrit (openstack-gerrit) wrote : Fix proposed to oslo.messaging (master)

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

Changed in oslo.messaging:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to oslo.messaging (master)

Reviewed: https://review.openstack.org/90111
Committed: https://git.openstack.org/cgit/openstack/oslo.messaging/commit/?id=8e3817593886b0b07c5053c0efafd5456a6a9513
Submitter: Jenkins
Branch: master

commit 8e3817593886b0b07c5053c0efafd5456a6a9513
Author: James Carey <email address hidden>
Date: Sun Apr 20 20:28:15 2014 +0000

    Enable log messages to handle exceptions containing unicode

    Currently the format string is a normal string, which in
    py2x is not unicode. When the unicode exception information is
    used to replace the %s, str() is called on it, but because
    it is unicode str() fails. Making the format string unicode
    fixes this. For the error log this is done by making it
    translatable and for the debug message by explicity making
    it unicode.

    The exception will contain unicode when the exception being
    returned by the other project is either translated to a
    language using unicode characters or when lazy translation
    is enabled and a gettextutils.Message instance is returned.

    Change-Id: I1706f5eb9dfbee434f8882b03dad4674d955c370
    Closes-Bug: #1310397

Changed in oslo.messaging:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in oslo.messaging:
milestone: none → juno-1
status: Fix Committed → Fix Released
Mark McLoughlin (markmc)
Changed in oslo.messaging:
importance: Undecided → Medium
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers