Drop support for standalone api service in CentOS/Ubuntu
Aodh no longer provides standalone api service and we should use httpd+wsgi to server api in CentOS and Ubuntu. This patch removes support for stnadalone api service in CentOS and Ubuntu and deprecates several parameters only used in standalone setup. Note that standalone service is still used in Debian since it provides services based on uwsgi, so the support is not dropped in Debian. Change-Id: I576b029fa3b0e765a9affd175f4113941d59abc7
This commit is contained in:
parent
f9b9656b17
commit
7ce34f01b6
|
@ -81,7 +81,8 @@ class aodh::api (
|
|||
}
|
||||
|
||||
if $manage_service {
|
||||
if $service_name == $::aodh::params::api_service_name {
|
||||
$api_service_name = $::aodh::params::api_service_name
|
||||
if $api_service_name != 'httpd' and $service_name == $api_service_name {
|
||||
if $enabled {
|
||||
$service_ensure = 'running'
|
||||
} else {
|
||||
|
@ -90,7 +91,7 @@ class aodh::api (
|
|||
|
||||
service { 'aodh-api':
|
||||
ensure => $service_ensure,
|
||||
name => $::aodh::params::api_service_name,
|
||||
name => $api_service_name,
|
||||
enable => $enabled,
|
||||
hasstatus => true,
|
||||
hasrestart => true,
|
||||
|
@ -98,19 +99,20 @@ class aodh::api (
|
|||
}
|
||||
} elsif $service_name == 'httpd' {
|
||||
include apache::params
|
||||
service { 'aodh-api':
|
||||
ensure => 'stopped',
|
||||
name => $::aodh::params::api_service_name,
|
||||
enable => false,
|
||||
tag => 'aodh-service',
|
||||
}
|
||||
Service <| title == 'httpd' |> { tag +> 'aodh-service' }
|
||||
|
||||
# we need to make sure aodh-api/eventlet is stopped before trying to start apache
|
||||
Service['aodh-api'] -> Service[$service_name]
|
||||
if $api_service_name != 'httpd' {
|
||||
service { 'aodh-api':
|
||||
ensure => 'stopped',
|
||||
name => $api_service_name,
|
||||
enable => false,
|
||||
tag => 'aodh-service',
|
||||
}
|
||||
# we need to make sure aodh-api/eventlet is stopped before trying to start apache
|
||||
Service['aodh-api'] -> Service[$service_name]
|
||||
}
|
||||
} else {
|
||||
fail("Invalid service_name. Either aodh/openstack-aodh-api for running \
|
||||
as a standalone service, or httpd for being run by a httpd server")
|
||||
fail('Invalid service_name.')
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ class aodh::params {
|
|||
'RedHat': {
|
||||
$common_package_name = 'openstack-aodh-common'
|
||||
$api_package_name = 'openstack-aodh-api'
|
||||
$api_service_name = 'openstack-aodh-api'
|
||||
$api_service_name = 'httpd'
|
||||
$notifier_package_name = 'openstack-aodh-notifier'
|
||||
$notifier_service_name = 'openstack-aodh-notifier'
|
||||
$evaluator_package_name = 'openstack-aodh-evaluator'
|
||||
|
@ -28,7 +28,14 @@ class aodh::params {
|
|||
'Debian': {
|
||||
$common_package_name = 'aodh-common'
|
||||
$api_package_name = 'aodh-api'
|
||||
$api_service_name = 'aodh-api'
|
||||
case $::operatingsystem {
|
||||
'Ubuntu': {
|
||||
$api_service_name = 'httpd'
|
||||
}
|
||||
default: {
|
||||
$api_service_name = 'aodh-api'
|
||||
}
|
||||
}
|
||||
$notifier_package_name = 'aodh-notifier'
|
||||
$notifier_service_name = 'aodh-notifier'
|
||||
$evaluator_package_name = 'aodh-evaluator'
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
upgrade:
|
||||
- |
|
||||
The ``aodh::api`` class no longer supports standalone api service in
|
||||
CentOS and Ubuntu, because these 2 distros don't provide standalone api
|
||||
service and require that wsgi is used to run the api service.
|
|
@ -3,7 +3,8 @@ require 'spec_helper'
|
|||
describe 'aodh::api' do
|
||||
|
||||
let :pre_condition do
|
||||
"class { 'aodh': }
|
||||
"include apache
|
||||
class { 'aodh': }
|
||||
include aodh::db
|
||||
class { 'aodh::keystone::authtoken':
|
||||
password => 'a_big_secret',
|
||||
|
@ -17,7 +18,7 @@ describe 'aodh::api' do
|
|||
}
|
||||
end
|
||||
|
||||
shared_examples 'aodh::api' do
|
||||
shared_examples 'aodh-api' do
|
||||
|
||||
it { is_expected.to contain_class('aodh::deps') }
|
||||
it { is_expected.to contain_class('aodh::params') }
|
||||
|
@ -40,27 +41,6 @@ describe 'aodh::api' do
|
|||
)
|
||||
end
|
||||
|
||||
[{:enabled => true}, {:enabled => false}].each do |param_hash|
|
||||
context "when service should be #{param_hash[:enabled] ? 'enabled' : 'disabled'}" do
|
||||
before do
|
||||
params.merge!(param_hash)
|
||||
end
|
||||
|
||||
it 'configures aodh-api service' do
|
||||
is_expected.to contain_service('aodh-api').with(
|
||||
:ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped',
|
||||
:name => platform_params[:api_service_name],
|
||||
:enable => params[:enabled],
|
||||
:hasstatus => true,
|
||||
:hasrestart => true,
|
||||
:tag => 'aodh-service',
|
||||
)
|
||||
end
|
||||
it { is_expected.to contain_service('aodh-api').that_subscribes_to('Anchor[aodh::service::begin]')}
|
||||
it { is_expected.to contain_service('aodh-api').that_notifies('Anchor[aodh::service::end]')}
|
||||
end
|
||||
end
|
||||
|
||||
context 'with sync_db set to true' do
|
||||
before do
|
||||
params.merge!(
|
||||
|
@ -104,6 +84,64 @@ describe 'aodh::api' do
|
|||
|
||||
it { is_expected.to contain_aodh_config('api/gnocchi_external_project_owner').with_value('gnocchi-project') }
|
||||
end
|
||||
|
||||
context 'when service_name is not valid' do
|
||||
before do
|
||||
params.merge!({ :service_name => 'foobar' })
|
||||
end
|
||||
|
||||
let :pre_condition do
|
||||
"include apache
|
||||
include aodh::db
|
||||
class { 'aodh': }
|
||||
class { 'aodh::keystone::authtoken':
|
||||
password => 'a_big_secret',
|
||||
}"
|
||||
end
|
||||
|
||||
it_raises 'a Puppet::Error', /Invalid service_name/
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
shared_examples_for 'aodh-api without standalone service' do
|
||||
|
||||
let :pre_condition do
|
||||
"include apache
|
||||
include aodh::db
|
||||
class { 'aodh': }
|
||||
class {'aodh::keystone::authtoken':
|
||||
password => 'password',
|
||||
}"
|
||||
end
|
||||
|
||||
it { is_expected.to_not contain_service('aodh-api') }
|
||||
end
|
||||
|
||||
|
||||
shared_examples 'aodh-api with standalone service' do
|
||||
|
||||
[{:enabled => true}, {:enabled => false}].each do |param_hash|
|
||||
context "when service should be #{param_hash[:enabled] ? 'enabled' : 'disabled'}" do
|
||||
before do
|
||||
params.merge!(param_hash)
|
||||
end
|
||||
|
||||
it 'configures aodh-api service' do
|
||||
is_expected.to contain_service('aodh-api').with(
|
||||
:ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped',
|
||||
:name => platform_params[:api_service_name],
|
||||
:enable => params[:enabled],
|
||||
:hasstatus => true,
|
||||
:hasrestart => true,
|
||||
:tag => 'aodh-service',
|
||||
)
|
||||
end
|
||||
it { is_expected.to contain_service('aodh-api').that_subscribes_to('Anchor[aodh::service::begin]')}
|
||||
it { is_expected.to contain_service('aodh-api').that_notifies('Anchor[aodh::service::end]')}
|
||||
end
|
||||
end
|
||||
|
||||
context 'with disabled service managing' do
|
||||
before do
|
||||
params.merge!({
|
||||
|
@ -139,23 +177,6 @@ describe 'aodh::api' do
|
|||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when service_name is not valid' do
|
||||
before do
|
||||
params.merge!({ :service_name => 'foobar' })
|
||||
end
|
||||
|
||||
let :pre_condition do
|
||||
"include apache
|
||||
include aodh::db
|
||||
class { 'aodh': }
|
||||
class { 'aodh::keystone::authtoken':
|
||||
password => 'a_big_secret',
|
||||
}"
|
||||
end
|
||||
|
||||
it_raises 'a Puppet::Error', /Invalid service_name/
|
||||
end
|
||||
end
|
||||
|
||||
on_supported_os({
|
||||
|
@ -172,15 +193,25 @@ describe 'aodh::api' do
|
|||
let(:platform_params) do
|
||||
case facts[:osfamily]
|
||||
when 'Debian'
|
||||
{ :api_package_name => 'aodh-api',
|
||||
:api_service_name => 'aodh-api' }
|
||||
if facts[:operatingsystem] == 'Ubuntu'
|
||||
{ :api_package_name => 'aodh-api',
|
||||
:api_service_name => 'httpd' }
|
||||
else
|
||||
{ :api_package_name => 'aodh-api',
|
||||
:api_service_name => 'aodh-api' }
|
||||
end
|
||||
when 'RedHat'
|
||||
{ :api_package_name => 'openstack-aodh-api',
|
||||
:api_service_name => 'openstack-aodh-api' }
|
||||
:api_service_name => 'httpd' }
|
||||
end
|
||||
end
|
||||
|
||||
it_behaves_like 'aodh::api'
|
||||
if facts[:osfamily] == 'Debian' and facts[:operatingsystem] != 'Ubuntu'
|
||||
it_behaves_like 'aodh-api with standalone service'
|
||||
else
|
||||
it_behaves_like 'aodh-api without standalone service'
|
||||
end
|
||||
it_behaves_like 'aodh-api'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue