Fix API service scheduling

Change-Id: I9e141b70d52d64b72555de7a15043303f57b5cc0
This commit is contained in:
Thomas Goirand
2018-12-13 12:38:12 +01:00
committed by Tobias Urdin
parent 25cf6d43d7
commit 7829638197
3 changed files with 27 additions and 44 deletions

View File

@@ -82,6 +82,10 @@ class cloudkitty::api (
enable => false, enable => false,
tag => 'cloudkitty-service', tag => 'cloudkitty-service',
} }
Service <| title == 'httpd' |> { tag +> 'cloudkitty-service' }
# we need to make sure cloudkitty-api/eventlet is stopped before trying to start apache
Service['cloudkitty-api'] -> Service[$service_name]
} else { } else {
fail('Invalid service_name. Only httpd for being run by a httpd server') fail('Invalid service_name. Only httpd for being run by a httpd server')
} }

View File

@@ -91,9 +91,12 @@ class cloudkitty::keystone::auth (
include cloudkitty::deps include cloudkitty::deps
if $configure_user_role { if $configure_user_role {
Keystone_user_role["${auth_name}@${tenant}"] ~> Anchor['cloudkitty::config::end'] Keystone_user_role["${auth_name}@${tenant}"] ~> Anchor['cloudkitty::service::end']
}
if $configure_endpoint {
Keystone_endpoint["${region}/${service_name}::${service_type}"] ~> Anchor['cloudkitty::service::end']
} }
Keystone_endpoint["${region}/${service_name}::${service_type}"] ~> Anchor['cloudkitty::config::end']
keystone::resource::service_identity { 'cloudkitty': keystone::resource::service_identity { 'cloudkitty':
configure_user => $configure_user, configure_user => $configure_user,
@@ -119,4 +122,3 @@ class cloudkitty::keystone::auth (
} }
} }

View File

@@ -10,15 +10,17 @@ describe 'cloudkitty::api' do
:pecan_debug => false } :pecan_debug => false }
end end
shared_examples_for 'cloudkitty-api' do let :pre_condition do
let :pre_condition do "include cloudkitty::db
"class { 'cloudkitty::keystone::authtoken': include apache
password => 'a_big_secret', class { 'cloudkitty': }
}" class { 'cloudkitty::keystone::authtoken':
end password => 'a_big_secret',
}"
context 'config params' do end
shared_examples 'cloudkitty-api' do
context 'with required params' do
it { is_expected.to contain_class('cloudkitty') } it { is_expected.to contain_class('cloudkitty') }
it { is_expected.to contain_class('cloudkitty::params') } it { is_expected.to contain_class('cloudkitty::params') }
it { is_expected.to contain_class('cloudkitty::deps') } it { is_expected.to contain_class('cloudkitty::deps') }
@@ -28,14 +30,13 @@ describe 'cloudkitty::api' do
it { is_expected.to contain_cloudkitty_config('api/port').with_value( params[:port] ) } it { is_expected.to contain_cloudkitty_config('api/port').with_value( params[:port] ) }
it { is_expected.to contain_cloudkitty_config('api/pecan_debug').with_value( params[:pecan_debug] ) } it { is_expected.to contain_cloudkitty_config('api/pecan_debug').with_value( params[:pecan_debug] ) }
end it 'installs cloudkitty-api package' do
is_expected.to contain_package('cloudkitty-api').with(
it 'installs cloudkitty-api package' do :ensure => 'present',
is_expected.to contain_package('cloudkitty-api').with( :name => platform_params[:api_package_name],
:ensure => 'present', :tag => ['openstack', 'cloudkitty-package'],
:name => platform_params[:api_package_name], )
:tag => ['openstack', 'cloudkitty-package'], end
)
end end
context 'when running cloudkitty-api in wsgi' do context 'when running cloudkitty-api in wsgi' do
@@ -43,15 +44,6 @@ describe 'cloudkitty::api' do
params.merge!({ :service_name => 'httpd' }) params.merge!({ :service_name => 'httpd' })
end end
let :pre_condition do
"include apache
include cloudkitty::db
class { 'cloudkitty': }
class { 'cloudkitty::keystone::authtoken':
password => 'a_big_secret',
}"
end
it 'configures cloudkitty-api service with Apache' do it 'configures cloudkitty-api service with Apache' do
is_expected.to contain_service('cloudkitty-api').with( is_expected.to contain_service('cloudkitty-api').with(
:ensure => 'stopped', :ensure => 'stopped',
@@ -67,15 +59,6 @@ describe 'cloudkitty::api' do
params.merge!({ :service_name => 'foobar' }) params.merge!({ :service_name => 'foobar' })
end end
let :pre_condition do
"include apache
include cloudkitty::db
class { 'cloudkitty': }
class { 'cloudkitty::keystone::authtoken':
password => 'a_big_secret',
}"
end
it_raises 'a Puppet::Error', /Invalid service_name/ it_raises 'a Puppet::Error', /Invalid service_name/
end end
@@ -85,11 +68,6 @@ describe 'cloudkitty::api' do
:sync_db => false, :sync_db => false,
}) })
end end
let :pre_condition do
"class { 'cloudkitty::keystone::authtoken':
password => 'a_big_secret',
}"
end
it 'configures cloudkitty-api service to not subscribe to the dbsync resource' do it 'configures cloudkitty-api service to not subscribe to the dbsync resource' do
is_expected.to contain_service('cloudkitty-api').that_subscribes_to(nil) is_expected.to contain_service('cloudkitty-api').that_subscribes_to(nil)
@@ -98,7 +76,7 @@ describe 'cloudkitty::api' do
end end
on_supported_os({ on_supported_os({
:supported_os => OSDefaults.get_supported_os :supported_os => OSDefaults.get_supported_os
}).each do |os,facts| }).each do |os,facts|
context "on #{os}" do context "on #{os}" do
let (:facts) do let (:facts) do
@@ -119,5 +97,4 @@ describe 'cloudkitty::api' do
it_behaves_like 'cloudkitty-api' it_behaves_like 'cloudkitty-api'
end end
end end
end end