Refactor resource dependencies

This refactors resource dependencies to improve the following points.

 - Avoid unnecessary dependencies across services. For example aodh
   service does not require cinder db.

 - Restart only api service when config files like paste.ini, which
   are used only be api service is changed.

Change-Id: I3953eea75f00c44363870c318f960b7299c65e7c
This commit is contained in:
Takashi Kajinami 2024-03-04 09:43:14 +09:00
parent 24988ff24b
commit a5fb242e23
7 changed files with 26 additions and 20 deletions

View File

@ -172,6 +172,11 @@ class cinder::api (
tag => 'cinder-service',
}
# On any api-paste.ini config change, we must restart Cinder API.
Cinder_api_paste_ini<||> ~> Service['cinder-api']
# On any uwsgi config change, we must restart Cinder API.
Cinder_api_uwsgi_config<||> ~> Service['cinder-api']
} elsif $service_name == 'httpd' {
service { 'cinder-api':
ensure => 'stopped',
@ -183,6 +188,10 @@ class cinder::api (
# we need to make sure cinder-api/eventlet is stopped before trying to start apache
Service['cinder-api'] -> Service[$service_name]
# On any api-paste.ini config change, we must restart Cinder API.
Cinder_api_paste_ini<||> ~> Service[$service_name]
} else {
fail("Invalid service_name. Either cinder-api/openstack-cinder-api for \
running as a standalone service, or httpd for being run by a httpd server")

View File

@ -17,4 +17,8 @@ class cinder::coordination (
oslo::coordination{ 'cinder_config':
backend_url => $backend_url
}
# all coordination settings should be applied and all packages should be
# installed before service startup
Oslo::Coordination['cinder_config'] -> Anchor['cinder::service::begin']
}

View File

@ -68,4 +68,8 @@ class cinder::db (
pool_timeout => $database_pool_timeout,
mysql_enable_ndb => $mysql_enable_ndb,
}
# all db settings should be applied and all packages should be installed
# before dbsync starts
Oslo::Db['cinder_config'] -> Anchor['cinder::dbsync::begin']
}

View File

@ -24,33 +24,17 @@ class cinder::deps {
~> Service<| tag == 'cinder-service' |>
~> anchor { 'cinder::service::end': }
# paste-api.ini config should occur in the config block also.
Anchor['cinder::config::begin']
-> Cinder_api_paste_ini<||>
~> Anchor['cinder::config::end']
-> Anchor['cinder::config::end']
# rootwrap config should occur in the config block also.
Anchor['cinder::config::begin']
-> Cinder_rootwrap_config<||>
~> Anchor['cinder::config::end']
# all coordination settings should be applied and all packages should be
# installed before service startup
Oslo::Coordination<||> -> Anchor['cinder::service::begin']
# all db settings should be applied and all packages should be installed
# before dbsync starts
Oslo::Db<||> -> Anchor['cinder::dbsync::begin']
# policy config should occur in the config block also.
Anchor['cinder::config::begin']
-> Openstacklib::Policy<| tag == 'cinder' |>
-> Anchor['cinder::config::end']
# On any uwsgi config change, we must restart Cinder API.
Anchor['cinder::config::begin']
-> Cinder_api_uwsgi_config<||>
~> Anchor['cinder::config::end']
-> Anchor['cinder::config::end']
# Support packages need to be installed in the install phase, but we don't
# put them in the chain above because we don't want any false dependencies

View File

@ -284,4 +284,6 @@ class cinder::keystone::authtoken(
service_type => $service_type,
interface => $interface;
}
Keystone::Resource::Authtoken['cinder_config'] -> Anchor['cinder::config::end']
}

View File

@ -70,6 +70,11 @@ class cinder::policy (
create_resources('openstacklib::policy', { $policy_path => $policy_parameters })
# policy config should occur in the config block also.
Anchor['cinder::config::begin']
-> Openstacklib::Policy[$policy_path]
-> Anchor['cinder::config::end']
oslo::policy { 'cinder_config':
enforce_scope => $enforce_scope,
enforce_new_defaults => $enforce_new_defaults,

View File

@ -33,7 +33,6 @@ describe 'cinder::policy' do
:file_group => 'cinder',
:file_format => 'yaml',
:purge_config => false,
:tag => 'cinder',
)
is_expected.to contain_oslo__policy('cinder_config').with(
:enforce_scope => false,
@ -64,7 +63,6 @@ describe 'cinder::policy' do
:file_group => 'cinder',
:file_format => 'yaml',
:purge_config => true,
:tag => 'cinder',
)
is_expected.to contain_oslo__policy('cinder_config').with(
:enforce_scope => false,