aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPiotr Milewski <vurmil@gmail.com>2026-03-16 17:02:19 +0100
committerPiotr Milewski <vurmil@gmail.com>2026-04-16 10:18:30 +0000
commit3e2982aacf428c33dd36d0d1a4110a87ccf351fc (patch)
treea3edbc76c8b88eb4bfeffa7ba89d33a17f8eaf1e
parent88aecb6009d2ef6e543849cd9930d1bd80cfca2f (diff)
downloadkolla-ansible-3e2982aacf428c33dd36d0d1a4110a87ccf351fc.tar.gz
kolla-ansible-3e2982aacf428c33dd36d0d1a4110a87ccf351fc.zip
horizon: add Valkey session cache backend and prefer it
Horizon may display "Something went wrong!" when a memcached node becomes unavailable. Add support for Valkey as a Horizon session cache backend using django-redis with Sentinel. Valkey is now preferred when enabled. If Valkey is not enabled, Memcached is used instead. This improves Horizon availability when cache nodes fail. Depends-On: https://review.opendev.org/c/openstack/kolla/+/980779 Closes-Bug: #2093414 Change-Id: I771754acc0febb466f4f921fdf29946d9e54f0c3 Signed-off-by: Piotr Milewski <vurmil@gmail.com>
-rw-r--r--ansible/group_vars/all/horizon.yml6
-rw-r--r--ansible/roles/horizon/templates/_9998-kolla-settings.py.j258
-rw-r--r--releasenotes/notes/bug-2093414-7cd37ece5c306507.yaml12
3 files changed, 65 insertions, 11 deletions
diff --git a/ansible/group_vars/all/horizon.yml b/ansible/group_vars/all/horizon.yml
index 8e477ad9c..d906f0408 100644
--- a/ansible/group_vars/all/horizon.yml
+++ b/ansible/group_vars/all/horizon.yml
@@ -38,6 +38,12 @@ enable_nova_horizon_policy_file: "{{ enable_nova }}"
# TLS
horizon_enable_tls_backend: "{{ kolla_enable_tls_backend }}"
+# Cache
+horizon_session_cache_backend: >-
+ {{ 'valkey' if enable_valkey | bool
+ else 'memcached' if enable_memcached | bool
+ else 'disabled' }}
+
# Ports
horizon_internal_fqdn: "{{ kolla_internal_fqdn }}"
horizon_external_fqdn: "{{ kolla_external_fqdn }}"
diff --git a/ansible/roles/horizon/templates/_9998-kolla-settings.py.j2 b/ansible/roles/horizon/templates/_9998-kolla-settings.py.j2
index 5c4fbd1ab..a0a86ef58 100644
--- a/ansible/roles/horizon/templates/_9998-kolla-settings.py.j2
+++ b/ansible/roles/horizon/templates/_9998-kolla-settings.py.j2
@@ -8,18 +8,54 @@ ALLOWED_HOSTS = ['*']
SESSION_ENGINE = 'django.contrib.sessions.backends.db'
DATABASES = {
'default': {
- 'ENGINE': 'django.db.backends.mysql',
- 'NAME': '{{ horizon_database_name }}',
- 'USER': '{{ horizon_database_user }}',
- 'PASSWORD': '{{ horizon_database_password }}',
- 'HOST': '{{ database_address }}',
- 'PORT': '{{ database_port }}'
+ 'ENGINE': 'django.db.backends.mysql',
+ 'NAME': '{{ horizon_database_name }}',
+ 'USER': '{{ horizon_database_user }}',
+ 'PASSWORD': '{{ horizon_database_password }}',
+ 'HOST': '{{ database_address }}',
+ 'PORT': '{{ database_port }}'
}
}
-{% elif groups['memcached'] | length > 0 and not horizon_backend_database | bool %}
+{% elif horizon_session_cache_backend == 'valkey' %}
SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
-CACHES['default']['LOCATION'] = [{% for host in groups['memcached'] %}'{{ 'api' | kolla_address(host) | put_address_in_context('url') }}:{{ memcached_port }}'{% if not loop.last %},{% endif %}{% endfor %}]
-CACHES['default']['OPTIONS'] = {'ignore_exc': True}
+CACHES = {
+ 'default': {
+ 'BACKEND': 'django_redis.cache.RedisCache',
+ 'LOCATION': 'redis://{{ valkey_sentinel_monitor_name }}/0',
+ 'OPTIONS': {
+ 'CLIENT_CLASS': 'django_redis.client.SentinelClient',
+ 'CONNECTION_FACTORY': 'django_redis.pool.SentinelConnectionFactory',
+ 'SENTINELS': [
+{% for host in groups['valkey'] %}
+ ('{{ 'api' | kolla_address(host) | put_address_in_context('url') }}', {{ valkey_sentinel_port }}),
+{% endfor %}
+ ],
+ 'SENTINEL_KWARGS': {
+ 'password': '{{ valkey_master_password }}',
+ },
+ 'PASSWORD': '{{ valkey_master_password }}',
+ 'CONNECTION_POOL_KWARGS': {
+ 'retry_on_timeout': True,
+ },
+ 'IGNORE_EXCEPTIONS': False,
+ }
+ }
+}
+{% elif horizon_session_cache_backend == 'memcached' %}
+SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
+CACHES = {
+ 'default': {
+ 'BACKEND': 'django.core.cache.backends.memcached.PyMemcacheCache',
+ 'LOCATION': [
+{% for host in groups['memcached'] %}
+ '{{ 'api' | kolla_address(host) | put_address_in_context('url') }}:{{ memcached_port }}'{% if not loop.last %},{% endif %}
+{% endfor %}
+ ],
+ 'OPTIONS': {
+ 'ignore_exc': True,
+ }
+ }
+}
{% endif %}
{% if kolla_enable_tls_external | bool or kolla_enable_tls_internal | bool %}
@@ -35,9 +71,9 @@ OPENSTACK_API_VERSIONS = {
OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = {{ horizon_keystone_multidomain | bool }}
OPENSTACK_KEYSTONE_DOMAIN_DROPDOWN = {{ 'True' if horizon_keystone_domain_choices | length > 1 else 'False' }}
OPENSTACK_KEYSTONE_DOMAIN_CHOICES = (
-{% for key, value in horizon_keystone_domain_choices.items() %}
+ {% for key, value in horizon_keystone_domain_choices.items() %}
('{{ key }}', '{{ value }}'),
-{% endfor %}
+ {% endfor %}
)
LOCAL_PATH = '/tmp'
diff --git a/releasenotes/notes/bug-2093414-7cd37ece5c306507.yaml b/releasenotes/notes/bug-2093414-7cd37ece5c306507.yaml
new file mode 100644
index 000000000..3b1d0ce59
--- /dev/null
+++ b/releasenotes/notes/bug-2093414-7cd37ece5c306507.yaml
@@ -0,0 +1,12 @@
+---
+upgrade:
+ - |
+ The default session cache backend for Horizon has changed when
+ Valkey is enabled. If ``enable_valkey`` is set to ``true``,
+ Valkey will be used as the preferred backend to improve
+ availability.
+fixes:
+ - |
+ Improves Horizon availability when cache nodes fail by adding
+ support for Valkey as a session cache backend.
+ `LP#2093414 <https://launchpad.net/bugs/2093414>`__