aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2026-04-16 21:17:18 +0000
committerGerrit Code Review <review@openstack.org>2026-04-16 21:17:18 +0000
commit3de4989045c34f8e0d28e8f704e4ce2c5ba5379e (patch)
treee69e11d01a0f33961ebec50939d560e8a9f69826
parenta2e9801f9157c0ed558c6adf1d84f7b60abbdada (diff)
parent3e2982aacf428c33dd36d0d1a4110a87ccf351fc (diff)
downloadkolla-ansible-3de4989045c34f8e0d28e8f704e4ce2c5ba5379e.tar.gz
kolla-ansible-3de4989045c34f8e0d28e8f704e4ce2c5ba5379e.zip
Merge "horizon: add Valkey session cache backend and prefer it"
-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>`__