cannot import name 'ugettext_lazy' from 'django.utils.translation'

Bug #2039226 reported by Corey Bryant
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Magnum UI
New
Undecided
Unassigned
OpenStack Dashboard Charm
Fix Committed
High
Corey Bryant
2023.2
Fix Committed
Undecided
Unassigned
Ubuntu Cloud Archive
Fix Released
High
Unassigned
Bobcat
Fix Released
High
Unassigned
watcher-dashboard
New
Undecided
Unassigned
magnum-ui (Ubuntu)
Fix Released
High
Unassigned
Mantic
Fix Released
High
Unassigned
watcher-dashboard (Ubuntu)
Fix Released
Undecided
Unassigned
Mantic
Fix Released
Undecided
Unassigned

Bug Description

On Ubuntu Mantic, the dashboard fails to load and the apache error log shows:

[Thu Oct 12 20:33:48.383727 2023] [wsgi:error] [pid 52899:tid 140293563209408] ERROR:root:cannot import name 'ugettext_lazy' from 'django.utils.translation' (/usr/lib/python3/dist-packages/django/utils/translation/__init__.py)
[Thu Oct 12 20:33:48.383757 2023] [wsgi:error] [pid 52899:tid 140293563209408] Traceback (most recent call last):
[Thu Oct 12 20:33:48.383764 2023] [wsgi:error] [pid 52899:tid 140293563209408] File "/usr/lib/python3/dist-packages/openstack_dashboard/utils/settings.py", line 58, in import_submodules
[Thu Oct 12 20:33:48.383769 2023] [wsgi:error] [pid 52899:tid 140293563209408] submodule = import_module(name)
[Thu Oct 12 20:33:48.383773 2023] [wsgi:error] [pid 52899:tid 140293563209408] ^^^^^^^^^^^^^^^^^^^
[Thu Oct 12 20:33:48.383777 2023] [wsgi:error] [pid 52899:tid 140293563209408] File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
[Thu Oct 12 20:33:48.383787 2023] [wsgi:error] [pid 52899:tid 140293563209408] return _bootstrap._gcd_import(name[level:], package, level)
[Thu Oct 12 20:33:48.383791 2023] [wsgi:error] [pid 52899:tid 140293563209408] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[Thu Oct 12 20:33:48.383795 2023] [wsgi:error] [pid 52899:tid 140293563209408] File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
[Thu Oct 12 20:33:48.383799 2023] [wsgi:error] [pid 52899:tid 140293563209408] File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
[Thu Oct 12 20:33:48.383803 2023] [wsgi:error] [pid 52899:tid 140293563209408] File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
[Thu Oct 12 20:33:48.383807 2023] [wsgi:error] [pid 52899:tid 140293563209408] File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
[Thu Oct 12 20:33:48.383811 2023] [wsgi:error] [pid 52899:tid 140293563209408] File "<frozen importlib._bootstrap_external>", line 940, in exec_module
[Thu Oct 12 20:33:48.383814 2023] [wsgi:error] [pid 52899:tid 140293563209408] File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
[Thu Oct 12 20:33:48.383818 2023] [wsgi:error] [pid 52899:tid 140293563209408] File "/usr/lib/python3/dist-packages/openstack_dashboard/enabled/_1370_project_container_infra_panel_group.py", line 14, in <module>
[Thu Oct 12 20:33:48.383823 2023] [wsgi:error] [pid 52899:tid 140293563209408] from django.utils.translation import ugettext_lazy as _

It looks like the charm template needs updating to work with Django 4.x in Mantic.

See upstream commit in horizon:

commit cd7c1b5110fe1f64cd9dfbeb1072b37912d0efee
Author: Akihiro Motoki <email address hidden>
Date: Wed Jan 26 22:42:15 2022 +0900

    Address RemovedInDjango40Warning (2)

    django.utils.translation.ugettext(), ugettext_lazy(), ugettext_noop(),
    ungettext(), and ungettext_lazy() are deprecated in favor of the
    functions that they’re aliases for: django.utils.translation.gettext(),
    gettext_lazy(), gettext_noop(), ngettext(), and ngettext_lazy().

    https://docs.djangoproject.com/en/4.0/releases/3.0/#id3

    Change-Id: I77878f84e9d10cf6a136dada81eabf4e18676250

== Ubuntu SRU Details ==

[Impact]
magnum dashboard can't be used with Django 4.x.

[Test Case]
Deploy openstack with magnum + magnum-ui. Ensure dashboard is functional and no errors in /var/log/apache/error.log.

[Regression Potential]
This is a pretty simple change to aliased functions and regression testing mentioned above should be good enough to ensure behavior is as expected. Currently the dashboard doesn't work on Mantic where Django is at 4.2.4. This package is backported to the Bobcat cloud archive on Jammy where Django is at 3.2.12 and will need testing there, however should be fine considering these functions were deprecated in Django 3.0.

Revision history for this message
Corey Bryant (corey.bryant) wrote :
Changed in watcher-dashboard (Ubuntu Mantic):
status: New → Fix Released
Revision history for this message
Corey Bryant (corey.bryant) wrote :
Revision history for this message
Corey Bryant (corey.bryant) wrote :
Download full text (7.7 KiB)

SRU details for magnum-ui

[Impact]

magnum dashboard can't be used with Django 4.x. See /var/log/apache/error.log:

[Thu Oct 12 21:11:53.240437 2023] [wsgi:error] [pid 71732:tid 140109883819712] [remote 10.5.3.66:56488] Could not import panel module magnum_ui.content.clusters.panel: cannot import name 'ugettext_lazy' from 'django.utils.translation' (/usr/lib/python3/dist-packages/django/utils/translation/__init__.py)
[Thu Oct 12 21:11:53.241129 2023] [wsgi:error] [pid 71732:tid 140109883819712] [remote 10.5.3.66:56488] Could not import panel module magnum_ui.content.cluster_templates.panel: cannot import name 'ugettext_lazy' from 'django.utils.translation' (/usr/lib/python3/dist-packages/django/utils/translation/__init__.py)
[Thu Oct 12 21:11:53.262688 2023] [wsgi:error] [pid 71732:tid 140109883819712] [remote 10.5.3.66:56488] Could not import panel module magnum_ui.content.container_infra.quotas.panel: cannot import name 'ugettext_lazy' from 'django.utils.translation' (/usr/lib/python3/dist-packages/django/utils/translation/__init__.py)
[Thu Oct 12 21:11:54.987658 2023] [wsgi:error] [pid 71733:tid 140109883819712] /usr/lib/python3/dist-packages/django/conf/__init__.py:267: RemovedInDjango50Warning: The USE_L10N setting is deprecated. Starting with Django 5.0, localized formatting of data will always be enabled. For example Django will display numbers and dates using the format of the current locale.
[Thu Oct 12 21:11:54.987699 2023] [wsgi:error] [pid 71733:tid 140109883819712] warnings.warn(USE_L10N_DEPRECATED_MSG, RemovedInDjango50Warning)
[Thu Oct 12 21:11:55.009599 2023] [wsgi:error] [pid 71733:tid 140109883819712] WARNING:root:Error importing openstack_dashboard.enabled._1370_project_container_infra_panel_group
[Thu Oct 12 21:11:55.011170 2023] [wsgi:error] [pid 71733:tid 140109883819712] ERROR:root:cannot import name 'ugettext_lazy' from 'django.utils.translation' (/usr/lib/python3/dist-packages/django/utils/translation/__init__.py)
[Thu Oct 12 21:11:55.011232 2023] [wsgi:error] [pid 71733:tid 140109883819712] Traceback (most recent call last):
[Thu Oct 12 21:11:55.011241 2023] [wsgi:error] [pid 71733:tid 140109883819712] File "/usr/lib/python3/dist-packages/openstack_dashboard/utils/settings.py", line 58, in import_submodules
[Thu Oct 12 21:11:55.011247 2023] [wsgi:error] [pid 71733:tid 140109883819712] submodule = import_module(name)
[Thu Oct 12 21:11:55.011253 2023] [wsgi:error] [pid 71733:tid 140109883819712] ^^^^^^^^^^^^^^^^^^^
[Thu Oct 12 21:11:55.011259 2023] [wsgi:error] [pid 71733:tid 140109883819712] File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
[Thu Oct 12 21:11:55.011265 2023] [wsgi:error] [pid 71733:tid 140109883819712] return _bootstrap._gcd_import(name[level:], package, level)
[Thu Oct 12 21:11:55.011271 2023] [wsgi:error] [pid 71733:tid 140109883819712] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[Thu Oct 12 21:11:55.011277 2023] [wsgi:error] [pid 71733:tid 140109883819712] File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
[Thu Oct 12 21:11:55.011283 2023] [wsgi:error] [pid 71733:tid 140109883819712] File "<frozen importli...

Read more...

Changed in magnum-ui (Ubuntu Mantic):
status: New → Triaged
importance: Undecided → High
Revision history for this message
Corey Bryant (corey.bryant) wrote :

If magnum-ui fix is needed before SRU lands, it is available in https://launchpad.net/~corey.bryant/+archive/ubuntu/mantic-bobcat

Changed in charm-openstack-dashboard:
status: New → Triaged
importance: Undecided → High
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to charm-openstack-dashboard (master)
Changed in charm-openstack-dashboard:
status: Triaged → In Progress
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package magnum-ui - 13.0.0-0ubuntu2

---------------
magnum-ui (13.0.0-0ubuntu2) noble; urgency=medium

  * d/p/drop-use-of-features-removed-in-django-4.0.patch: Cherry-picked
    from upstream to provide support for Django 4 (LP: #2039226).
  * d/gbp.conf, .launchpad.yaml: Sync from cloud-archive-tools for
    caracal.

 -- Corey Bryant <email address hidden> Fri, 13 Oct 2023 10:52:20 -0400

Changed in magnum-ui (Ubuntu):
status: Triaged → Fix Released
Revision history for this message
Steve Langasek (vorlon) wrote :

please provide a complete test case for this SRU.

Changed in magnum-ui (Ubuntu Mantic):
status: Triaged → Incomplete
Revision history for this message
Corey Bryant (corey.bryant) wrote (last edit ):

Hi Steve, I just wanted to make sure you saw the [Test Case] section in https://bugs.launchpad.net/cloud-archive/+bug/2039226/comments/3. I should have probably put that in the Description, just didn't want to polute the upstream bug. Or did you want more details in the [Test Case]? Thanks for taking a look!

Changed in magnum-ui (Ubuntu Mantic):
status: Incomplete → Triaged
Revision history for this message
Timo Aaltonen (tjaalton) wrote :

leave the extra debugging output out of the description, but the SRU info still belongs there

Changed in magnum-ui (Ubuntu Mantic):
status: Triaged → Fix Committed
tags: added: verification-needed verification-needed-mantic
Revision history for this message
Timo Aaltonen (tjaalton) wrote : Please test proposed package

Hello Corey, or anyone else affected,

Accepted magnum-ui into mantic-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/magnum-ui/13.0.0-0ubuntu1.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-mantic to verification-done-mantic. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-mantic. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

description: updated
Revision history for this message
Corey Bryant (corey.bryant) wrote :

Hello Corey, or anyone else affected,

Accepted magnum-ui into bobcat-proposed. The package will build now and be available in the Ubuntu Cloud Archive in a few hours, and then in the -proposed repository.

Please help us by testing this new package. To enable the -proposed repository:

  sudo add-apt-repository cloud-archive:bobcat-proposed
  sudo apt-get update

Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-bobcat-needed to verification-bobcat-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-bobcat-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

tags: added: verification-bobcat-needed
Changed in cloud-archive:
status: Triaged → Fix Released
Revision history for this message
Corey Bryant (corey.bryant) wrote :

Verified successfully on mantic-proposed python3-magnum-ui/mantic-proposed,now 13.0.0-0ubuntu1.1.

Revision history for this message
Corey Bryant (corey.bryant) wrote :

Verified successfully on mantic-proposed python3-magnum-ui/mantic-proposed,now 13.0.0-0ubuntu1.1.

tags: added: verification-done verification-done-mantic
removed: verification-needed verification-needed-mantic
Revision history for this message
Corey Bryant (corey.bryant) wrote :

Verified successfully on bobcat-proposedpython3-magnum-ui/jammy-proposed,now 13.0.0-0ubuntu1.1~cloud0

tags: added: verification-bobcat-done
removed: verification-bobcat-needed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to charm-openstack-dashboard (master)

Reviewed: https://review.opendev.org/c/openstack/charm-openstack-dashboard/+/898246
Committed: https://opendev.org/openstack/charm-openstack-dashboard/commit/16c5a026419e5c23ab4e7777cec8deb15c25ee6f
Submitter: "Zuul (22348)"
Branch: master

commit 16c5a026419e5c23ab4e7777cec8deb15c25ee6f
Author: Corey Bryant <email address hidden>
Date: Fri Oct 13 14:57:46 2023 -0400

    Add local_settings.py template for Bobcat

    This fixes issues found in testing with Django 4 in mantic.

    ugettext_lazy was deprecated in Django 3.0 and removed in
    Django 4.0. Switch to gettext_lazy.

    Switch to PyMemcacheCache backend as the Django MemcachedCache
    backend was removed in Django 4.1 in favor of the PyMemcacheCache
    or PyLibMCCache backend. This depends on a new openstack-dashboard
    package version that will be provided in an SRU for bug #2039225.

    Closes-Bug: #2039226
    Closes-Bug: #2039225
    Change-Id: Ia8e4f6f5f50d58268e4c6fa80c9f9c65a56a26ea

Changed in charm-openstack-dashboard:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to charm-openstack-dashboard (stable/2023.2)
Felipe Reyes (freyes)
Changed in charm-openstack-dashboard:
assignee: nobody → Corey Bryant (corey.bryant)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to charm-openstack-dashboard (stable/2023.2)

Reviewed: https://review.opendev.org/c/openstack/charm-openstack-dashboard/+/901561
Committed: https://opendev.org/openstack/charm-openstack-dashboard/commit/dec3e0158f0fc7c484e3fc2ffd8fa31c166f9b58
Submitter: "Zuul (22348)"
Branch: stable/2023.2

commit dec3e0158f0fc7c484e3fc2ffd8fa31c166f9b58
Author: Corey Bryant <email address hidden>
Date: Fri Oct 13 14:57:46 2023 -0400

    Add local_settings.py template for Bobcat

    This fixes issues found in testing with Django 4 in mantic.

    ugettext_lazy was deprecated in Django 3.0 and removed in
    Django 4.0. Switch to gettext_lazy.

    Switch to PyMemcacheCache backend as the Django MemcachedCache
    backend was removed in Django 4.1 in favor of the PyMemcacheCache
    or PyLibMCCache backend. This depends on a new openstack-dashboard
    package version that will be provided in an SRU for bug #2039225.

    Closes-Bug: #2039226
    Closes-Bug: #2039225
    Change-Id: Ia8e4f6f5f50d58268e4c6fa80c9f9c65a56a26ea
    (cherry picked from commit 16c5a026419e5c23ab4e7777cec8deb15c25ee6f)

Revision history for this message
Brian Murray (brian-murray) wrote : Update Released

The verification of the Stable Release Update for magnum-ui has completed successfully and the package is now being released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package magnum-ui - 13.0.0-0ubuntu1.1

---------------
magnum-ui (13.0.0-0ubuntu1.1) mantic; urgency=medium

  * d/p/drop-use-of-features-removed-in-django-4.0.patch: Cherry-picked
    from upstream to provide support for Django 4 (LP: #2039226).
  * d/gbp.conf: Create stable/2023.2 branch.
  * d/gbp.conf, .launchpad.yaml: Sync from cloud-archive-tools for
    bobcat.

 -- Corey Bryant <email address hidden> Fri, 13 Oct 2023 10:52:20 -0400

Changed in magnum-ui (Ubuntu Mantic):
status: Fix Committed → Fix Released
Revision history for this message
Corey Bryant (corey.bryant) wrote :

The verification of the Stable Release Update for magnum-ui has completed successfully and the package has now been released to -updates. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Revision history for this message
Corey Bryant (corey.bryant) wrote :

This bug was fixed in the package magnum-ui - 13.0.0-0ubuntu1.1~cloud0
---------------

 magnum-ui (13.0.0-0ubuntu1.1~cloud0) jammy-bobcat; urgency=medium
 .
   * New update for the Ubuntu Cloud Archive.
 .
 magnum-ui (13.0.0-0ubuntu1.1) mantic; urgency=medium
 .
   * d/p/drop-use-of-features-removed-in-django-4.0.patch: Cherry-picked
     from upstream to provide support for Django 4 (LP: #2039226).
   * d/gbp.conf: Create stable/2023.2 branch.
   * d/gbp.conf, .launchpad.yaml: Sync from cloud-archive-tools for
     bobcat.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/magnum-ui 14.0.0.0rc1

This issue was fixed in the openstack/magnum-ui 14.0.0.0rc1 release candidate.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/watcher-dashboard 11.0.0.0rc1

This issue was fixed in the openstack/watcher-dashboard 11.0.0.0rc1 release candidate.

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.