openstack-k8s-operators / horizon-operator

Apache License 2.0
1 stars 26 forks source link

Custom config is not applied #302

Open xek opened 7 months ago

xek commented 7 months ago

I tried to apply the following config:

oc get cm horizon-config-data -o jsonpath={.data} | jq '."9999_custom_settings.py"'
"SESSION_ENGINE = 'django.contrib.sessions.backends.signed_cookies'\nCACHES = {\n  \"default\": {\n    \"BACKEND\": \"django.core.cache.backends.filebased.FileBasedCache\",\n    \"LOCATION\": \"/var/tmp/django_cache\",\n  }\n}\n"

The service still fails connecting to memcached, since I have TLS enabled. On furthter inspection, I see that the settings are not applied:

[root@horizon-696978b96-2vqpw /]# ./usr/share/openstack-dashboard/manage.py shell
Python 3.9.18 (main, Jan 24 2024, 00:00:00) 
[GCC 11.4.1 20231218 (Red Hat 11.4.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import settings
WARNING:root:"dashboards" and "default_dashboard" in (local_)settings is DEPRECATED now and may be unsupported in some future release. The preferred way to specify the order of dashboards and the default dashboard is the pluggable dashboard mechanism (in /usr/share/openstack-dashboard/openstack_dashboard/enabled, /usr/share/openstack-dashboard/openstack_dashboard/local/enabled).
>>> settings.SESSION_ENGINE
'django.contrib.sessions.backends.cache'
>>> 

I think there needs to be an import in local_settings.py to import all of the files from the /etc/openstack-dashboard/local_settings.d/directory.

deshipu commented 7 months ago

It already loads all files from /usr/share/openstack-dashboard/openstack_dashboard/local/local_settings.d:

https://github.com/openstack/horizon/blob/master/openstack_dashboard/settings.py#L268-L280

xek commented 7 months ago

Oh, I haven't seen that. Maybe the issue is that the local_settings.py, which is also placed in this directory, overwrites the contents of 9999_custom_settings.py? I guess it should be renamed to 0000_local_settings.py

https://github.com/openstack-k8s-operators/horizon-operator/blob/dd46fc11a8f4abccf76870a688c15e69c37baebf/templates/horizon/config/horizon.json#L27

I'll take a second look once I have it deployed again.

deshipu commented 7 months ago

No, local_settings.py is loaded before local_settings.d, and renaming it will just result in it not being found at all.

The problem is that you are putting things in /etc/openstack-dashboard/local_settings.d but the application doesn't know about it and checks its own directories at /usr/share/openstack-dashboard/openstack_dashboard/local/local_settings.d.

TripleO didn't like that and moved some (but not all) of the configuration files to /etc, replacing them with symlinks.

The horizon-operator assumed those files should be in /etc just like TripleO did, but doesn't create the symlinks (only the symlink for /etc/openstack-dashboard/local_settings is created). So nothing works.

deshipu commented 7 months ago

Be the way, we can (and should) just put the memcached config in the local_settings directly, that's how we did it originally with puppet-horizon.

deshipu commented 7 months ago

Those symlinks are also required for the plugins and the downstream theme to work.