From fc72a83bccebd211466bdeb6e1e1d7c2cc3b22f5 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Wed, 31 Aug 2022 02:36:10 +0900 Subject: [PATCH] cache: Ensure pymemcache library is installed The pymemcache library should be installed when pymemcache backend is used but this library is not required by the oslo.cache library or its dependencies and should be installed additionally. Closes-Bug: #1988205 Change-Id: I9422af416e74c53e09f6216bcbeab234337ccbae --- manifests/cache.pp | 6 ++ .../notes/bug-1988205-973ce17f355cbfce.yaml | 5 ++ spec/defines/oslo_cache_spec.rb | 61 +++++++++++++++++-- 3 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 releasenotes/notes/bug-1988205-973ce17f355cbfce.yaml diff --git a/manifests/cache.pp b/manifests/cache.pp index 6d22eac..54bde2b 100644 --- a/manifests/cache.pp +++ b/manifests/cache.pp @@ -269,6 +269,12 @@ define oslo::cache( name => $::oslo::params::python_memcache_package_name, tag => ['openstack'], }) + } elsif ($backend =~ /\.pymemcache/ ) { + ensure_packages('python-pymemcache', { + ensure => $package_ensure, + name => $::oslo::params::python_pymemcache_package_name, + tag => ['openstack'], + }) } elsif ($backend =~ /\.etcd3gw/ ) { ensure_packages('python-etcd3gw', { name => $::oslo::params::python_etcd3gw_package_name, diff --git a/releasenotes/notes/bug-1988205-973ce17f355cbfce.yaml b/releasenotes/notes/bug-1988205-973ce17f355cbfce.yaml new file mode 100644 index 0000000..f95cda9 --- /dev/null +++ b/releasenotes/notes/bug-1988205-973ce17f355cbfce.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Now the ``oslo::cache`` defined resource type installs + the pymemcache library when pymemcache backend is used. diff --git a/spec/defines/oslo_cache_spec.rb b/spec/defines/oslo_cache_spec.rb index a018132..b3492a3 100644 --- a/spec/defines/oslo_cache_spec.rb +++ b/spec/defines/oslo_cache_spec.rb @@ -197,6 +197,53 @@ describe 'oslo::cache' do end end + context 'with pymemcache backend' do + let :params do + { + :backend => 'dogpile.cache.pymemcache', + :memcache_servers => ['host1:11211', 'host2:11211','[fd12:3456:789a:1::1]:11211'], + } + end + + it 'configures cache backend' do + is_expected.to contain_keystone_config('cache/backend').with_value('dogpile.cache.pymemcache') + is_expected.to contain_keystone_config('cache/memcache_servers').with_value('host1:11211,host2:11211,[fd12:3456:789a:1::1]:11211') + is_expected.to contain_package('python-pymemcache').with( + :ensure => 'installed', + :name => platform_params[:python_pymemcache_package_name], + :tag => ['openstack'], + ) + end + + context 'with package_ensure set' do + before do + params.merge!({ + :package_ensure => 'latest' + }) + end + + it 'ensures status of the package' do + is_expected.to contain_package('python-pymemcache').with( + :ensure => 'latest', + :name => platform_params[:python_pymemcache_package_name], + :tag => ['openstack'], + ) + end + end + + context 'with backend package management disabled' do + before do + params.merge!({ + :manage_backend_package => false, + }) + end + + it 'does not install backend package' do + is_expected.not_to contain_package('python-pymemcache') + end + end + end + context 'with etcd3gw backend' do let :params do { @@ -270,13 +317,15 @@ describe 'oslo::cache' do let(:platform_params) do case facts[:osfamily] when 'Debian' - { :pylibmc_package_name => 'python3-pylibmc', - :python_memcache_package_name => 'python3-memcache', - :python_etcd3gw_package_name => 'python3-etcd3gw' } + { :pylibmc_package_name => 'python3-pylibmc', + :python_memcache_package_name => 'python3-memcache', + :python_etcd3gw_package_name => 'python3-etcd3gw', + :python_pymemcache_package_name => 'python3-pymemcache' } when 'RedHat' - { :pylibmc_package_name => 'python3-pylibmc', - :python_memcache_package_name => 'python3-memcached', - :python_etcd3gw_package_name => 'python3-etcd3gw' } + { :pylibmc_package_name => 'python3-pylibmc', + :python_memcache_package_name => 'python3-memcached', + :python_etcd3gw_package_name => 'python3-etcd3gw', + :python_pymemcache_package_name => 'python3-pymemcache' } end end