Merge "Properly notify apache restarts on cinder configuration updates"

This commit is contained in:
Zuul 2019-08-20 13:27:29 +00:00 committed by Gerrit Code Review
commit 11ee82bb4d
4 changed files with 49 additions and 9 deletions

View File

@ -92,3 +92,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 = {