enable_lazy should be deprecated/removed

Bug #1801761 reported by Matt Riedemann
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo.i18n
Triaged
Medium
Unassigned
oslo.upgradecheck
Fix Released
High
Ben Nemec

Bug Description

As seen in a few projects that are implementing the upgrade-checkers command goal for Stein, using the oslo_i18n.enable_lazy() hook causes issues with the upgrade check command output:

http://paste.openstack.org/show/734156/

osboxes@osboxes:~/git/searchlight$ tox -e venv -- searchlight-status upgrade check
venv develop-inst-noop: /home/osboxes/git/searchlight
venv installed: amqp==2.3.2,appdirs==1.4.3,asn1crypto==0.24.0,attrs==18.2.0,Babel==2.6.0,cachetools==2.1.0,certifi==2018.10.15,cffi==1.11.5,chardet==3.0.4,cliff==2.14.0,cmd2==0.9.6,colorama==0.4.0,contextlib2==0.5.5,coverage==4.5.1,cryptography==2.3.1,debtcollector==1.20.0,decorator==4.3.0,dnspython==1.15.0,dogpile.cache==0.6.7,elasticsearch==2.4.1,eventlet==0.24.1,extras==1.0.0,fasteners==0.14.1,fixtures==3.0.0,flake8==2.2.4,future==0.17.1,futurist==1.7.0,greenlet==0.4.15,hacking==0.10.3,httplib2==0.11.3,idna==2.7,iso8601==0.1.12,Jinja2==2.10,jmespath==0.9.3,jsonpatch==1.23,jsonpointer==2.0,jsonschema==2.6.0,keystoneauth1==3.11.1,keystonemiddleware==5.3.0,kombu==4.2.1,linecache2==1.0.0,MarkupSafe==1.0,mccabe==0.2.1,mock==2.0.0,monotonic==1.5,mox3==0.26.0,msgpack==0.5.6,munch==2.3.2,netaddr==0.7.19,netifaces==0.10.7,openstacksdk==0.19.0,os-client-config==1.31.2,os-service-types==1.3.0,osc-lib==1.11.1,oslo.cache==1.31.1,oslo.concurrency==3.28.1,oslo.config==6.6.2,oslo.context==2.21.0,oslo.i18n==3.22.1,oslo.log==3.40.1,oslo.messaging==9.1.1,oslo.middleware==3.36.0,oslo.policy==1.40.1,oslo.serialization==2.28.1,oslo.service==1.32.0,oslo.upgradecheck==0.1.0,oslo.utils==3.37.1,oslotest==3.7.0,osprofiler==2.5.0,Paste==3.0.3,PasteDeploy==1.5.2,pbr==5.1.0,pep8==1.5.7,prettytable==0.7.2,psutil==5.4.8,pycadf==2.8.0,pycparser==2.19,pyflakes==0.8.1,pyinotify==0.9.6,pyOpenSSL==18.0.0,pyparsing==2.3.0,pyperclip==1.7.0,python-cinderclient==4.1.0,python-dateutil==2.7.5,python-designateclient==2.11.0,python-glanceclient==2.14.0,python-ironicclient==2.5.0,python-keystoneclient==3.18.0,python-mimeparse==1.6.0,python-neutronclient==6.10.0,python-novaclient==11.1.0,python-subunit==1.3.0,python-swiftclient==3.6.0,pytz==2018.7,PyYAML==3.13,repoze.lru==0.7,requests==2.20.0,requestsexceptions==1.4.0,rfc3986==1.1.0,Routes==2.4.1,-e git://git.openstack.org/openstack/searchlight@e9b47947ade21b13c9c8fc14ba42420dbf0707ee#egg=searchlight,simplegeneric==0.8.1,simplejson==3.16.0,six==1.11.0,statsd==3.3.0,stestr==2.1.1,stevedore==1.30.0,testtools==2.3.0,traceback2==1.4.0,unittest2==1.1.0,urllib3==1.24.1,vine==1.1.4,voluptuous==0.11.5,warlock==1.3.0,wcwidth==0.1.7,WebOb==1.8.3,wrapt==1.10.11,WSME==0.9.3
venv runtests: PYTHONHASHSEED='1392988093'
venv runtests: commands[0] | searchlight-status upgrade check
Error:
Traceback (most recent call last):
  File "/home/osboxes/git/searchlight/.tox/venv/lib/python3.5/site-packages/oslo_upgradecheck/upgradecheck.py", line 184, in main
    return conf.command.action_fn()
  File "/home/osboxes/git/searchlight/.tox/venv/lib/python3.5/site-packages/oslo_upgradecheck/upgradecheck.py", line 134, in check
    print(t)
  File "/home/osboxes/git/searchlight/.tox/venv/lib/python3.5/site-packages/prettytable.py", line 237, in __str__
    return self.__unicode__()
  File "/home/osboxes/git/searchlight/.tox/venv/lib/python3.5/site-packages/prettytable.py", line 243, in __unicode__
    return self.get_string()
  File "/home/osboxes/git/searchlight/.tox/venv/lib/python3.5/site-packages/prettytable.py", line 995, in get_string
    lines.append(self._stringify_header(options))
  File "/home/osboxes/git/searchlight/.tox/venv/lib/python3.5/site-packages/prettytable.py", line 1066, in _stringify_header
    bits.append(" " * lpad + self._justify(fieldname, width, self._align[field]) + " " * rpad)
  File "/home/osboxes/git/searchlight/.tox/venv/lib/python3.5/site-packages/prettytable.py", line 187, in _justify
    return text + excess * " "
  File "/home/osboxes/git/searchlight/.tox/venv/lib/python3.5/site-packages/oslo_i18n/_message.py", line 230, in __add__
    raise TypeError(msg)
TypeError: Message objects do not support addition.

The lazy translation effort from IBM was abandoned several years ago and these "big tent" projects are probably just still calling this code because it was copied from nova or glance originally, but that's all been removed from the core projects (or should have been by now). Anyway, it causes issues and isn't supported, so we should work to deprecate and remove the enable_lazy translation code from oslo.i18n.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to oslo.upgradecheck (master)

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

Changed in oslo.upgradecheck:
assignee: nobody → Ben Nemec (bnemec)
status: New → In Progress
Revision history for this message
Ben Nemec (bnemec) wrote :

For posterity, here's the gist of our IRC discussion about this:

Nobody had any objections to deprecating this functionality, although we should probably socialize that discussion further. Since we can't do a deprecation and removal within this cycle, we are going to fix the problem in oslo.upgradecheck to unblock that work. We can then pursue the oslo.i18n deprecation in a less urgent manner.

Changed in oslo.upgradecheck:
importance: Undecided → High
Changed in oslo.i18n:
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
Matt Riedemann (mriedem) wrote :
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to oslo.upgradecheck (master)

Reviewed: https://review.openstack.org/615610
Committed: https://git.openstack.org/cgit/openstack/oslo.upgradecheck/commit/?id=c4283dd0ebbb2e64947b966e51b7f3f47233b7be
Submitter: Zuul
Branch: master

commit c4283dd0ebbb2e64947b966e51b7f3f47233b7be
Author: Ben Nemec <email address hidden>
Date: Mon Nov 5 17:09:58 2018 +0000

    Force translation of table header

    Concatenation of lazily translated strings using + is not supported,
    but prettytable is doing that internally with one of the translated
    strings that we pass in. Use six.text_type to force immediate
    translation of the string before passing it to prettytable.

    Change-Id: I73929f9df85a9856bb70b37ee08f5399f98fdb00
    Closes-Bug: 1801761

Changed in oslo.upgradecheck:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/oslo.upgradecheck 0.1.1

This issue was fixed in the openstack/oslo.upgradecheck 0.1.1 release.

Revision history for this message
Luigi Toscano (ltoscano) wrote :

I just noticed that we (Sahara) use it. Is there a suggested path for migrating out of it?

Revision history for this message
Ben Nemec (bnemec) wrote :

You can stop using it today by just removing the enable_lazy call(s) from your code. That will cause oslo.i18n to use the regular translation code internally instead of the lazy framework.

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.