From a802b575dee18f8034b2a2a4c9ab80b5f231684a Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Wed, 17 Apr 2024 14:18:55 +0900 Subject: [PATCH] Make sure python3-redis is installed ... when RedisCache is used Change-Id: Iaf5dae66cfbc505fdd829630eaec9127b4185247 --- manifests/init.pp | 8 +++ manifests/params.pp | 2 + spec/classes/horizon_init_spec.rb | 89 ++++++++++++++++++++----------- 3 files changed, 69 insertions(+), 30 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index d793c946..21a0c1d6 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -695,6 +695,14 @@ Use PyMemcacheCache backend instead") Anchor['horizon::install::begin'] -> Package<| name == $::horizon::params::pymemcache_package |> -> Anchor['horizon::install::end'] + } elsif $cache_backend =~ /\.RedisCache$/ { + ensure_packages('python-redis', { + name => $::horizon::params::python_redis_package, + tag => ['openstack'], + }) + Anchor['horizon::install::begin'] + -> Package<| name == $::horizon::params::python_redis_package |> + -> Anchor['horizon::install::end'] } } diff --git a/manifests/params.pp b/manifests/params.pp index 854ac12c..66810059 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -23,6 +23,7 @@ class horizon::params { $wsgi_group = 'apache' $memcache_package = 'python3-memcached' $pymemcache_package = 'python3-pymemcache' + $python_redis_package = 'python3-redis' $designate_dashboard_package_name = 'openstack-designate-ui' $heat_dashboard_package_name = 'openstack-heat-ui' $ironic_dashboard_package_name = 'openstack-ironic-ui' @@ -41,6 +42,7 @@ class horizon::params { $wsgi_group = 'horizon' $memcache_package = 'python3-memcache' $pymemcache_package = 'python3-pymemcache' + $python_redis_package = 'python3-redis' $designate_dashboard_package_name = 'python3-designate-dashboard' $heat_dashboard_package_name = 'python3-heat-dashboard' $ironic_dashboard_package_name = 'python3-ironic-ui' diff --git a/spec/classes/horizon_init_spec.rb b/spec/classes/horizon_init_spec.rb index 149de4de..9e21fe2a 100644 --- a/spec/classes/horizon_init_spec.rb +++ b/spec/classes/horizon_init_spec.rb @@ -364,6 +364,32 @@ describe 'horizon' do it { is_expected.not_to contain_package('python-pymemcache') } end + context 'installs python redis library when cache_backend is set to redis' do + before do + params.merge!({ + :cache_backend => 'django.core.cache.backends.redis.RedisCache', + }) + end + + it { + is_expected.to contain_package('python-redis').with( + :tag => ['openstack'], + :name => platforms_params[:python_redis_package], + ) + } + end + + context 'does not install python redis when manage_memcache_package set to false' do + before do + params.merge!({ + :cache_backend => 'django.core.cache.backends.redis.RedisCache', + :manage_memcache_package => false + }) + end + + it { is_expected.not_to contain_package('python-redis') } + end + context 'with custom wsgi options' do before do params.merge!( :wsgi_processes => '30', @@ -795,41 +821,44 @@ describe 'horizon' do case facts[:os]['family'] when 'Debian' if facts[:os]['name'] == 'Debian' - { :config_file => '/etc/openstack-dashboard/local_settings.py', - :conf_d_dir => '/etc/openstack-dashboard/local_settings.d', - :secret_key_file => '/etc/openstack-dashboard/.secret_key_store', - :package_name => 'openstack-dashboard-apache', - :root_url => '/horizon', - :root_path => '/var/lib/openstack-dashboard', - :memcache_package => 'python3-memcache', - :pymemcache_package => 'python3-pymemcache', - :wsgi_user => 'horizon', - :wsgi_group => 'horizon', + { :config_file => '/etc/openstack-dashboard/local_settings.py', + :conf_d_dir => '/etc/openstack-dashboard/local_settings.d', + :secret_key_file => '/etc/openstack-dashboard/.secret_key_store', + :package_name => 'openstack-dashboard-apache', + :root_url => '/horizon', + :root_path => '/var/lib/openstack-dashboard', + :memcache_package => 'python3-memcache', + :pymemcache_package => 'python3-pymemcache', + :python_redis_package => 'python3-redis', + :wsgi_user => 'horizon', + :wsgi_group => 'horizon', } else - { :config_file => '/etc/openstack-dashboard/local_settings.py', - :conf_d_dir => '/etc/openstack-dashboard/local_settings.d', - :secret_key_file => '/etc/openstack-dashboard/.secret_key_store', - :package_name => 'openstack-dashboard', - :root_url => '/horizon', - :root_path => '/var/lib/openstack-dashboard', - :memcache_package => 'python3-memcache', - :pymemcache_package => 'python3-pymemcache', - :wsgi_user => 'horizon', - :wsgi_group => 'horizon', + { :config_file => '/etc/openstack-dashboard/local_settings.py', + :conf_d_dir => '/etc/openstack-dashboard/local_settings.d', + :secret_key_file => '/etc/openstack-dashboard/.secret_key_store', + :package_name => 'openstack-dashboard', + :root_url => '/horizon', + :root_path => '/var/lib/openstack-dashboard', + :memcache_package => 'python3-memcache', + :pymemcache_package => 'python3-pymemcache', + :python_redis_package => 'python3-redis', + :wsgi_user => 'horizon', + :wsgi_group => 'horizon', } end when 'RedHat' - { :config_file => '/etc/openstack-dashboard/local_settings', - :conf_d_dir => '/etc/openstack-dashboard/local_settings.d', - :secret_key_file => '/etc/openstack-dashboard/.secret_key_store', - :package_name => 'openstack-dashboard', - :root_url => '/dashboard', - :root_path => '/usr/share/openstack-dashboard', - :memcache_package => 'python3-memcached', - :pymemcache_package => 'python3-pymemcache', - :wsgi_user => 'apache', - :wsgi_group => 'apache', + { :config_file => '/etc/openstack-dashboard/local_settings', + :conf_d_dir => '/etc/openstack-dashboard/local_settings.d', + :secret_key_file => '/etc/openstack-dashboard/.secret_key_store', + :package_name => 'openstack-dashboard', + :root_url => '/dashboard', + :root_path => '/usr/share/openstack-dashboard', + :memcache_package => 'python3-memcached', + :pymemcache_package => 'python3-pymemcache', + :python_redis_package => 'python3-redis', + :wsgi_user => 'apache', + :wsgi_group => 'apache', } end end