Properly notify apache restarts on cinder configuration updates

This uses edit_resource to add a notification in the block storage
apache configuration when it gets updated. This is a workaround due to
the fact we are using a version of the apache2 cookbook that is still
using definitions and cannot add notifications with definitions.

This will be removed in the Stein release when we migrate to the newer
apache2 cookbook which uses proper resources.

Change-Id: I7efddef83333ca0794ee3c298ca1a2488defe941
Signed-off-by: Lance Albertson <lance@osuosl.org>
This commit is contained in:
Lance Albertson
2019-07-09 12:56:37 -07:00
parent f2a4e0c7ee
commit 0566bf9578
4 changed files with 49 additions and 9 deletions

View File

@@ -82,3 +82,19 @@ web_app 'cinder-api' do
protocol node['openstack']['block-storage']['ssl']['protocol']
ciphers node['openstack']['block-storage']['ssl']['ciphers']
end
# Hack until Apache cookbook has lwrp's for proper use of notify restart
# apache2 after keystone if completely configured. Whenever a cinder
# config is updated, have it notify the resource which clears the lock
# so the service can be restarted.
# TODO(ramereth): This should be removed once this cookbook is updated
# to use the newer apache2 cookbook which uses proper resources.
edit_resource(:template, "#{node['apache']['dir']}/sites-available/cinder-api.conf") do
notifies :run, 'execute[Clear cinder-api apache restart]', :immediately
end
execute 'cinder-api apache restart' do
command "touch #{Chef::Config[:file_cache_path]}/cinder-api-apache-restarted"
creates "#{Chef::Config[:file_cache_path]}/cinder-api-apache-restarted"
notifies :restart, 'service[apache2]', :immediately
end

View File

@@ -83,13 +83,8 @@ end
# merge all config options and secrets to be used in the cinder.conf.erb
cinder_conf_options = merge_config_options 'block-storage'
service 'cinder-apache2' do
case node['platform_family']
when 'debian'
service_name 'apache2'
when 'rhel'
service_name 'httpd'
end
execute 'Clear cinder-api apache restart' do
command "rm -f #{Chef::Config[:file_cache_path]}/cinder-api-apache-restarted"
action :nothing
end
@@ -102,7 +97,7 @@ template '/etc/cinder/cinder.conf' do
variables(
service_config: cinder_conf_options
)
notifies :restart, 'service[cinder-apache2]'
notifies :run, 'execute[Clear cinder-api apache restart]', :immediately
end
# delete all secrets saved in the attribute

View File

@@ -12,7 +12,35 @@ describe 'openstack-block-storage::api' do
include_context 'block-storage-stubs'
include_examples 'common-logging'
include_examples 'creates_cinder_conf', 'service[cinder-apache2]', 'cinder', 'cinder'
include_examples 'creates_cinder_conf', 'execute[Clear cinder-api apache restart]', 'cinder', 'cinder', 'run'
it do
expect(chef_run).to nothing_execute('Clear cinder-api apache restart')
.with(
command: 'rm -f /var/chef/cache/cinder-api-apache-restarted'
)
end
%w(
/etc/cinder/cinder.conf
/etc/apache2/sites-available/cinder-api.conf
).each do |f|
it "#{f} notifies execute[Clear cinder-api apache restart]" do
expect(chef_run.template(f)).to notify('execute[Clear cinder-api apache restart]').to(:run).immediately
end
end
it do
expect(chef_run).to run_execute('cinder-api apache restart')
.with(
command: 'touch /var/chef/cache/cinder-api-apache-restarted',
creates: '/var/chef/cache/cinder-api-apache-restarted'
)
end
it do
expect(chef_run.execute('cinder-api apache restart')).to notify('service[apache2]').to(:restart).immediately
end
it 'upgrades cinder api packages' do
expect(chef_run).to upgrade_package('cinder-api')

View File

@@ -13,6 +13,7 @@ RSpec.configure do |config|
config.color = true
config.formatter = :documentation
config.log_level = :fatal
config.file_cache_path = '/var/chef/cache'
end
REDHAT_OPTS = {