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: Iadb8552abf55228729bf5d31795b1e4bbb8b9929
This commit is contained in:
Takashi Kajinami 2024-03-01 02:28:54 +09:00
parent fb2d047f0c
commit d9840e99d0
8 changed files with 36 additions and 22 deletions

View File

@ -104,6 +104,12 @@ class heat::api (
hasrestart => true,
tag => 'heat-service',
}
# On any paste-api.ini config change, we must restart Heat API.
Heat_api_paste_ini<||> ~> Service['heat-api']
# On any uwsgi config change, we must restart Heat API.
Heat_api_uwsgi_config<||> ~> Service['heat-api']
} elsif $service_name == 'httpd' {
service { 'heat-api':
ensure => 'stopped',
@ -115,6 +121,10 @@ class heat::api (
# we need to make sure heat-api/eventlet is stopped before trying to start apache
Service['heat-api'] -> Service[$service_name]
# On any paste-api.ini config change, we must restart Heat API.
Heat_api_paste_ini<||> ~> Service[$service_name]
} else {
fail("Invalid service_name. Either heat-api/openstack-heat-api for \
running as a standalone service, or httpd for being run by a httpd server")

View File

@ -107,6 +107,12 @@ class heat::api_cfn (
hasrestart => true,
tag => 'heat-service',
}
# On any paste-api.ini config change, we must restart Heat API.
Heat_api_paste_ini<||> ~> Service['heat-api-cfn']
# On any uwsgi config change, we must restart Heat API.
Heat_api_cfn_uwsgi_config<||> ~> Service['heat-api-cfn']
} elsif $service_name == 'httpd' {
service { 'heat-api-cfn':
ensure => 'stopped',
@ -118,6 +124,10 @@ class heat::api_cfn (
# we need to make sure heat-api-cfn/eventlet is stopped before trying to start apache
Service['heat-api-cfn'] -> Service[$service_name]
# On any paste-api.ini config change, we must restart Heat API.
Heat_api_paste_ini<||> ~> Service[$service_name]
} else {
fail("Invalid service_name. Either heat-api-cfn/openstack-heat-api-cfn for \
running as a standalone service, or httpd for being run by a httpd server")

View File

@ -277,6 +277,10 @@ class heat::cache (
dead_timeout => $dead_timeout,
}
# all cache settings should be applied and all packages should be installed
# before service startup
Oslo::Cache['heat_config'] -> Anchor['heat::service::begin']
heat_config {
'constraint_validation_cache/caching': value => $constraint_validation_caching;
'constraint_validation_cache/expiration_time': value => $constraint_validation_expiration_time;

View File

@ -78,4 +78,7 @@ class heat::db (
include heat::db::sync
}
# all db settings should be applied and all packages should be installed
# before dbsync starts
Oslo::Db['heat_config'] -> Anchor['heat::dbsync::begin']
}

View File

@ -24,33 +24,17 @@ class heat::deps {
~> Service<| tag == 'heat-service' |>
~> anchor { 'heat::service::end': }
# paste-api.ini config should occur in the config block also.
Anchor['heat::config::begin']
-> Heat_api_paste_ini<||>
~> Anchor['heat::config::end']
# all cache settings should be applied and all packages should be installed
# before service startup
Oslo::Cache<||> -> Anchor['heat::service::begin']
# policy config should occur in the config block also.
Anchor['heat::config::begin']
-> Openstacklib::Policy<| tag == 'heat' |>
-> Anchor['heat::config::end']
# On any uwsgi config change, we must restart Heat API.
Anchor['heat::config::begin']
-> Heat_api_uwsgi_config<||>
~> Anchor['heat::config::end']
-> Anchor['heat::config::end']
# On any uwsgi config change, we must restart Heat API CFN.
Anchor['heat::config::begin']
-> Heat_api_cfn_uwsgi_config<||>
~> Anchor['heat::config::end']
# all db settings should be applied and all packages should be installed
# before dbsync starts
Oslo::Db<||> -> Anchor['heat::dbsync::begin']
-> Anchor['heat::config::end']
# Installation or config changes will always restart services.
Anchor['heat::install::end'] ~> Anchor['heat::service::begin']

View File

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

View File

@ -65,11 +65,15 @@ class heat::policy (
file_group => $::heat::params::group,
file_format => 'yaml',
purge_config => $purge_config,
tag => 'heat',
}
create_resources('openstacklib::policy', { $policy_path => $policy_parameters })
# policy config should occur in the config block also.
Anchor['heat::config::begin']
-> Openstacklib::Policy[$policy_path]
-> Anchor['heat::config::end']
oslo::policy { 'heat_config':
enforce_scope => $enforce_scope,
enforce_new_defaults => $enforce_new_defaults,
@ -77,5 +81,4 @@ class heat::policy (
policy_default_rule => $policy_default_rule,
policy_dirs => $policy_dirs,
}
}

View File

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