Control: found -1 3:14.0.2-3+deb10u2
Control: retitle -1 openstack-dashboard: fails to (re-)configure after a plugin 
was removed but not purged

On 05/05/2021 22.19, Thomas Goirand wrote:
Thanks a lot for opening this bug, this brings light into a major defect
of the Horizon plugin packaging.

What happens is that the various python3-FOO-<dashboard/ui> packages are
installing files in /etc/openstack-dashboard/enable. As they are in
/etc, they are CONFFILEs, and they aren't removed when the package is
removed, only when the package is actually purged.

When Horizon ugprades, it starts its "collecstatic" dance, meaning that
it loads its settings, and therefore, tries to load whatever is
described in /etc/openstack-dashboard/enable. And it fails because the
actual code, called from the "enable" folder, is gone (since the plugin
was removed).

So this actually is a bug in the plugins, that should have, to begin
with, removed the files they own in /etc/openstack-dashboard/enable
during the removal. I don't think this bug can be counted in Horizon itself.

That explains pretty clear what is going on here.
So the 50000 install-remove-distupgrade-install buster->bullseye
tests actually found a nice bug ;-)

Easier receipe to reproduce (tested in buster, probably works in bullseye, too)

DEBIAN_FRONTEND=noninteractive apt-get install python3-cloudkitty-dashboard
dpkg -r python3-cloudkitty-dashboard
DEBIAN_FRONTEND=noninteractive dpkg-reconfigure openstack-dashboard

Now, I'm unsure what to do. These plugins should be fixed in Bullseye,
though the issue you reported is with packages from Buster. So the
various plugin packages must be fixed in Buster for this bug to be closed.

I have no idea how this could be fixed in the plugins ...
The conffiles must not be touched (e.g. deleted or edited) upon
removal, otherwise things will explode (or just not work any
more) after reinstall.

I quickly tried guarding the import:

--- /usr/lib/python3/dist-packages/openstack_dashboard/utils/settings.py.orig   
2021-05-05 21:13:28.789477232 +0000
+++ /usr/lib/python3/dist-packages/openstack_dashboard/utils/settings.py        
2021-05-05 21:05:39.617000280 +0000
@@ -127,7 +127,11 @@
if config.get('AUTO_DISCOVER_STATIC_FILES', False):
             for _app in _apps:
+              try:
                 module = import_module(_app)
+              except ModuleNotFoundError:
+                print("NOT INSTALLED:", _app)
+              else:
                 base_path = os.path.join(module.__path__[0], 'static/')
                 file_discovery.populate_horizon_config(horizon_config,
                                                        base_path)

which works, but there are more locations to be fixed.
Could still be easier than fixing all the plugins now.

Next failure is

NOT INSTALLED: cloudkittydashboard
Traceback (most recent call last):
  File "/usr/share/openstack-dashboard/manage.py", line 23, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", 
line 364, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python3/dist-packages/django/core/management/__init__.py", 
line 338, in execute
    django.setup()
  File "/usr/lib/python3/dist-packages/django/__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/lib/python3/dist-packages/django/apps/registry.py", line 85, in 
populate
    app_config = AppConfig.create(entry)
  File "/usr/lib/python3/dist-packages/django/apps/config.py", line 94, in 
create
    module = import_module(entry)
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'cloudkittydashboard'

That can be solved with

--- /usr/lib/python3/dist-packages/django/apps/registry.py.orig 2021-05-05 
21:22:03.673994464 +0000
+++ /usr/lib/python3/dist-packages/django/apps/registry.py      2021-05-05 
21:24:41.910153200 +0000
@@ -82,7 +82,11 @@
                 if isinstance(entry, AppConfig):
                     app_config = entry
                 else:
+                  try:
                     app_config = AppConfig.create(entry)
+                  except ModuleNotFoundError:
+                    print("NOT INSTALLED:", entry)
+                    continue
                 if app_config.label in self.app_configs:
                     raise ImproperlyConfigured(
                         "Application labels aren't unique, "

And with that patched as well, openstack-dashboard.postinst
at least no longer fails.
But I have no idea if it is still working.
Nor what else it might break.
Not even what it is ;-)

What do you suggest then? Should I attempt to fix the plugins in both
Buster and Bullseye they?

That needs to be fixed (or at least worked around) in
buster and bullseye. Somehow. ;-)
And maybe the design error can be fixed for bookworm.

Andreas

Reply via email to