Restart apache only where appropriate
The current code tries to restart apache for every change to
/etc/nova/nova.conf even on compute nodes that do not have apache
installed. This changeset splits out the apache service resource into a
separate recipe that (unlike nova-common) is not included by the compute
recipe.
Conflicts: recipes/placement_api.rb
Added version bump.
Change-Id: I87dda61dfabec460fe042b4cee21277382dd9487
(cherry picked from commit 5747451dcb
)
This commit is contained in:

committed by
Jens Harbott

parent
1cc3c07aa7
commit
7953fbe8c2
@@ -5,7 +5,7 @@ issues_url 'https://launchpad.net/openstack-chef'
|
|||||||
source_url 'https://opendev.org/openstack/cookbook-openstack-compute'
|
source_url 'https://opendev.org/openstack/cookbook-openstack-compute'
|
||||||
license 'Apache-2.0'
|
license 'Apache-2.0'
|
||||||
description 'The OpenStack Compute service Nova.'
|
description 'The OpenStack Compute service Nova.'
|
||||||
version '19.1.0'
|
version '19.2.0'
|
||||||
|
|
||||||
chef_version '>= 15.0'
|
chef_version '>= 15.0'
|
||||||
|
|
||||||
|
32
recipes/_nova_apache.rb
Normal file
32
recipes/_nova_apache.rb
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# encoding: UTF-8
|
||||||
|
#
|
||||||
|
# Cookbook:: openstack-compute
|
||||||
|
# Recipe:: _nova_apache
|
||||||
|
#
|
||||||
|
# Copyright:: 2019-2020, Oregon State University
|
||||||
|
# Copyright:: 2020, x-ion GmbH
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
include_recipe 'openstack-compute::nova-common'
|
||||||
|
|
||||||
|
# service['apache2'] is defined in the apache2_default_install resource
|
||||||
|
# but other resources are currently unable to reference it. To work
|
||||||
|
# around this issue, define the following helper in your cookbook:
|
||||||
|
service 'apache2' do
|
||||||
|
extend Apache2::Cookbook::Helpers
|
||||||
|
service_name lazy { apache_platform_service_name }
|
||||||
|
supports restart: true, status: true, reload: true
|
||||||
|
action :nothing
|
||||||
|
subscribes :restart, 'template[/etc/nova/nova.conf]'
|
||||||
|
end
|
@@ -28,7 +28,7 @@ class ::Chef::Recipe
|
|||||||
include Apache2::Cookbook::Helpers
|
include Apache2::Cookbook::Helpers
|
||||||
end
|
end
|
||||||
|
|
||||||
include_recipe 'openstack-compute::nova-common'
|
include_recipe 'openstack-compute::_nova_apache'
|
||||||
|
|
||||||
platform_options = node['openstack']['compute']['platform']
|
platform_options = node['openstack']['compute']['platform']
|
||||||
|
|
||||||
|
@@ -25,7 +25,7 @@ class ::Chef::Recipe
|
|||||||
include Apache2::Cookbook::Helpers
|
include Apache2::Cookbook::Helpers
|
||||||
end
|
end
|
||||||
|
|
||||||
include_recipe 'openstack-compute::nova-common'
|
include_recipe 'openstack-compute::_nova_apache'
|
||||||
|
|
||||||
platform_options = node['openstack']['compute']['platform']
|
platform_options = node['openstack']['compute']['platform']
|
||||||
|
|
||||||
|
@@ -188,16 +188,6 @@ end
|
|||||||
# merge all config options and secrets to be used in nova.conf
|
# merge all config options and secrets to be used in nova.conf
|
||||||
nova_conf_options = merge_config_options 'compute'
|
nova_conf_options = merge_config_options 'compute'
|
||||||
|
|
||||||
# service['apache2'] is defined in the apache2_default_install resource
|
|
||||||
# but other resources are currently unable to reference it. To work
|
|
||||||
# around this issue, define the following helper in your cookbook:
|
|
||||||
service 'apache2' do
|
|
||||||
extend Apache2::Cookbook::Helpers
|
|
||||||
service_name lazy { apache_platform_service_name }
|
|
||||||
supports restart: true, status: true, reload: true
|
|
||||||
action :nothing
|
|
||||||
end
|
|
||||||
|
|
||||||
template '/etc/nova/nova.conf' do
|
template '/etc/nova/nova.conf' do
|
||||||
source 'openstack-service.conf.erb'
|
source 'openstack-service.conf.erb'
|
||||||
cookbook 'openstack-common'
|
cookbook 'openstack-common'
|
||||||
@@ -210,7 +200,6 @@ template '/etc/nova/nova.conf' do
|
|||||||
# with the glance_api_servers configuration option...
|
# with the glance_api_servers configuration option...
|
||||||
service_config: nova_conf_options
|
service_config: nova_conf_options
|
||||||
)
|
)
|
||||||
notifies :restart, 'service[apache2]'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# delete all secrets saved in the attribute
|
# delete all secrets saved in the attribute
|
||||||
|
@@ -24,7 +24,7 @@ class ::Chef::Recipe
|
|||||||
include Apache2::Cookbook::Helpers
|
include Apache2::Cookbook::Helpers
|
||||||
end
|
end
|
||||||
|
|
||||||
include_recipe 'openstack-compute::nova-common'
|
include_recipe 'openstack-compute::_nova_apache'
|
||||||
include_recipe 'openstack-compute::_nova_cell'
|
include_recipe 'openstack-compute::_nova_cell'
|
||||||
|
|
||||||
# Create valid apache site configuration file before installing package
|
# Create valid apache site configuration file before installing package
|
||||||
|
22
spec/_nova_apache_spec.rb
Normal file
22
spec/_nova_apache_spec.rb
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# encoding: UTF-8
|
||||||
|
|
||||||
|
require_relative 'spec_helper'
|
||||||
|
|
||||||
|
describe 'openstack-compute::_nova_apache' do
|
||||||
|
describe 'ubuntu' do
|
||||||
|
let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
|
||||||
|
let(:node) { runner.node }
|
||||||
|
cached(:chef_run) { runner.converge(described_recipe) }
|
||||||
|
|
||||||
|
include_context 'compute_stubs'
|
||||||
|
|
||||||
|
it do
|
||||||
|
expect(chef_run).to include_recipe('openstack-compute::nova-common')
|
||||||
|
end
|
||||||
|
|
||||||
|
it do
|
||||||
|
expect(chef_run.service('apache2')).to \
|
||||||
|
subscribe_to('template[/etc/nova/nova.conf]').on(:restart)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@@ -9,7 +9,7 @@ describe 'openstack-compute::api-metadata' do
|
|||||||
cached(:chef_run) { runner.converge(described_recipe) }
|
cached(:chef_run) { runner.converge(described_recipe) }
|
||||||
|
|
||||||
include_context 'compute_stubs'
|
include_context 'compute_stubs'
|
||||||
include_examples 'expect_runs_nova_common_recipe'
|
include_examples 'expect_runs_nova_apache_recipe'
|
||||||
include_examples 'expect_creates_nova_state_dir'
|
include_examples 'expect_creates_nova_state_dir'
|
||||||
include_examples 'expect_creates_nova_lock_dir'
|
include_examples 'expect_creates_nova_lock_dir'
|
||||||
|
|
||||||
|
@@ -9,7 +9,7 @@ describe 'openstack-compute::api-metadata' do
|
|||||||
cached(:chef_run) { runner.converge(described_recipe) }
|
cached(:chef_run) { runner.converge(described_recipe) }
|
||||||
|
|
||||||
include_context 'compute_stubs'
|
include_context 'compute_stubs'
|
||||||
include_examples 'expect_runs_nova_common_recipe'
|
include_examples 'expect_runs_nova_apache_recipe'
|
||||||
include_examples 'expect_creates_nova_state_dir'
|
include_examples 'expect_creates_nova_state_dir'
|
||||||
include_examples 'expect_creates_nova_lock_dir'
|
include_examples 'expect_creates_nova_lock_dir'
|
||||||
include_examples 'expect_creates_api_paste_template'
|
include_examples 'expect_creates_api_paste_template'
|
||||||
|
@@ -9,7 +9,7 @@ describe 'openstack-compute::api-os-compute' do
|
|||||||
cached(:chef_run) { runner.converge(described_recipe) }
|
cached(:chef_run) { runner.converge(described_recipe) }
|
||||||
|
|
||||||
include_context 'compute_stubs'
|
include_context 'compute_stubs'
|
||||||
include_examples 'expect_runs_nova_common_recipe'
|
include_examples 'expect_runs_nova_apache_recipe'
|
||||||
include_examples 'expect_creates_nova_state_dir'
|
include_examples 'expect_creates_nova_state_dir'
|
||||||
include_examples 'expect_creates_nova_lock_dir'
|
include_examples 'expect_creates_nova_lock_dir'
|
||||||
|
|
||||||
|
@@ -9,7 +9,7 @@ describe 'openstack-compute::api-os-compute' do
|
|||||||
cached(:chef_run) { runner.converge(described_recipe) }
|
cached(:chef_run) { runner.converge(described_recipe) }
|
||||||
|
|
||||||
include_context 'compute_stubs'
|
include_context 'compute_stubs'
|
||||||
include_examples 'expect_runs_nova_common_recipe'
|
include_examples 'expect_runs_nova_apache_recipe'
|
||||||
include_examples 'expect_creates_nova_state_dir'
|
include_examples 'expect_creates_nova_state_dir'
|
||||||
include_examples 'expect_creates_nova_lock_dir'
|
include_examples 'expect_creates_nova_lock_dir'
|
||||||
include_examples 'expect_creates_api_paste_template'
|
include_examples 'expect_creates_api_paste_template'
|
||||||
|
@@ -72,10 +72,6 @@ describe 'openstack-compute::nova-common' do
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it do
|
|
||||||
expect(chef_run.template('/etc/nova/nova.conf')).to notify('service[apache2]').to(:restart)
|
|
||||||
end
|
|
||||||
|
|
||||||
it '[DEFAULT]' do
|
it '[DEFAULT]' do
|
||||||
[
|
[
|
||||||
%r{^log_dir = /var/log/nova$},
|
%r{^log_dir = /var/log/nova$},
|
||||||
|
@@ -9,7 +9,7 @@ describe 'openstack-compute::placement_api' do
|
|||||||
cached(:chef_run) { runner.converge(described_recipe) }
|
cached(:chef_run) { runner.converge(described_recipe) }
|
||||||
|
|
||||||
include_context 'compute_stubs'
|
include_context 'compute_stubs'
|
||||||
include_examples 'expect_runs_nova_common_recipe'
|
include_examples 'expect_runs_nova_apache_recipe'
|
||||||
include_examples 'expect_creates_nova_state_dir'
|
include_examples 'expect_creates_nova_state_dir'
|
||||||
include_examples 'expect_creates_nova_lock_dir'
|
include_examples 'expect_creates_nova_lock_dir'
|
||||||
|
|
||||||
|
@@ -10,9 +10,7 @@ describe 'openstack-compute::placement_api' do
|
|||||||
|
|
||||||
include_context 'compute_stubs'
|
include_context 'compute_stubs'
|
||||||
|
|
||||||
it 'includes nova-common recipe' do
|
include_examples 'expect_runs_nova_apache_recipe'
|
||||||
expect(chef_run).to include_recipe 'openstack-compute::nova-common'
|
|
||||||
end
|
|
||||||
|
|
||||||
it do
|
it do
|
||||||
expect(chef_run).to upgrade_package %w(python3-nova libapache2-mod-wsgi-py3 nova-placement-api)
|
expect(chef_run).to upgrade_package %w(python3-nova libapache2-mod-wsgi-py3 nova-placement-api)
|
||||||
|
@@ -140,6 +140,12 @@ shared_examples 'expect_volume_packages' do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
shared_examples 'expect_runs_nova_apache_recipe' do
|
||||||
|
it 'includes _nova_apache' do
|
||||||
|
expect(chef_run).to include_recipe 'openstack-compute::_nova_apache'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
shared_examples 'expect_runs_nova_common_recipe' do
|
shared_examples 'expect_runs_nova_common_recipe' do
|
||||||
it 'includes nova-common' do
|
it 'includes nova-common' do
|
||||||
expect(chef_run).to include_recipe 'openstack-compute::nova-common'
|
expect(chef_run).to include_recipe 'openstack-compute::nova-common'
|
||||||
|
Reference in New Issue
Block a user