A lot of Heat code doesn't work with gettext lazy translation enabled

Bug #1281644 reported by Christopher Armstrong
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
Critical
Thomas Herve

Bug Description

Lazy evaluation was recently enabled for Heat services, but a lot of code in Heat does things to the result of _() that won't work with lazy evaluation enabled.

The easiest way to see this is to enable lazy evaluation for the unit tests and try to run them. Add the lines:

    from heat.openstack.common import gettextutils
    gettextutils.enable_lazy()
    gettextutils.install('heat', lazy=True)

to heat/tests/__init__.py, and then try to run the tests, and you'll see it in action.

Thomas Herve (therve)
Changed in heat:
assignee: nobody → Thomas Herve (therve)
milestone: none → icehouse-3
importance: Undecided → Critical
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to heat (master)

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

Changed in heat:
status: New → In Progress
Revision history for this message
Jason Dunsmore (jasondunsmore) wrote :

Can you give instructions on how to reproduce the bug without modifying code?

Revision history for this message
Thomas Herve (therve) wrote :

I haven't tried, but I suspect that create a stack with a OS::Nova::Server, delete the server, and suspend the stack, should show the bug. We have the errors in tempest logs too.

Revision history for this message
Zane Bitter (zaneb) wrote :

I ran into this where I broke a tempest test and the resulting error was lost in favour of some unhelpful message about the translation.

Revision history for this message
Zane Bitter (zaneb) wrote :

Here it is:

Details: {u'title': u'Bad Request', u'explanation': u'The server could not comply with the request since it is either malformed or otherwise incorrect.', u'code': 400, u'error': {u'message': u'Message objects do not support str() because they may contain non-ascii characters. Please use unicode() or translate() instead.', u'traceback': u'Traceback (most recent call last):\n\n File "/opt/stack/new/heat/heat/openstack/common/rpc/amqp.py", line 462, in _process_data\n **args)\n\n File "/opt/stack/new/heat/heat/openstack/common/rpc/dispatcher.py", line 172, in dispatch\n result = getattr(proxyobj, method)(ctxt, **kwargs)\n\n File "/opt/stack/new/heat/heat/engine/service.py", line 63, in wrapped\n return func(self, ctx, *args, **kwargs)\n\n File "/opt/stack/new/heat/heat/engine/service.py", line 413, in create_stack\n stack.validate()\n\n File "/opt/stack/new/heat/heat/engine/parser.py", line 351, in validate\n six.text_type(ex)))\n\nStackValidationFailed: Message objects do not support str() because they may contain non-ascii characters. Please use unicode() or translate() instead.\n', u'type': u'StackValidationFailed'}}

So just feed in a template that fails validation and you're pretty much guaranteed to see this.

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

Reviewed: https://review.openstack.org/74454
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=8b1b7d132e7565e2c48b34039ec6742df390c5d9
Submitter: Jenkins
Branch: master

commit 8b1b7d132e7565e2c48b34039ec6742df390c5d9
Author: Thomas Herve <email address hidden>
Date: Tue Feb 18 18:56:16 2014 +0100

    Revert "Merge "Re-enable lazy translation""

    Revert enabling lazy translation, which doesn't work in many places
    because we're doing string concatenation.

    This reverts commit 1864efa320aadbb4f5503c15345dd363bb3691c1, reversing
    changes made to 92e3e3ce74dc1e3f75d51600072227c2e44016a6.

    Closes-Bug: #1281644
    Change-Id: Iac0be685f8bb60f81715c0dd3dbe35787e38ee39

Changed in heat:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in heat:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in heat:
milestone: icehouse-3 → 2014.1
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.