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: Ie9922c101e7981801c4c8c8753f0ce54ac8e5fe3
This commit is contained in:
Takashi Kajinami
2024-01-30 01:13:10 +09:00
parent 39d3dcc438
commit fb448c80b5
6 changed files with 19 additions and 20 deletions

View File

@@ -119,6 +119,11 @@ class aodh::api (
} }
} }
# On any paste-api.ini config change, we must restart Aodh API.
Aodh_api_paste_ini<||> ~> Service[$service_name]
# On any uwsgi config change, we must restart Aodh API.
Aodh_api_uwsgi_config<||> ~> Service[$service_name]
aodh_config { aodh_config {
'api/gnocchi_external_project_owner': value => $gnocchi_external_project_owner; 'api/gnocchi_external_project_owner': value => $gnocchi_external_project_owner;
'api/gnocchi_external_domain_name': value => $gnocchi_external_domain_name; 'api/gnocchi_external_domain_name': value => $gnocchi_external_domain_name;

View File

@@ -41,4 +41,8 @@ class aodh::coordination (
'coordination/retry_backoff': value => $retry_backoff; 'coordination/retry_backoff': value => $retry_backoff;
'coordination/max_retry_interval': value => $max_retry_interval; 'coordination/max_retry_interval': value => $max_retry_interval;
} }
# all coordination settings should be applied and all packages should be
# installed before service startup
Oslo::Coordination['aodh_config'] -> Anchor['aodh::service::begin']
} }

View File

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

View File

@@ -24,28 +24,13 @@ class aodh::deps {
~> Service<| tag == 'aodh-service' |> ~> Service<| tag == 'aodh-service' |>
~> anchor { 'aodh::service::end': } ~> anchor { 'aodh::service::end': }
# paste-api.ini config should occur in the config block also.
Anchor['aodh::config::begin'] Anchor['aodh::config::begin']
-> Aodh_api_paste_ini<||> -> Aodh_api_paste_ini<||>
~> Anchor['aodh::config::end']
# all coordination settings should be applied and all packages should be
# installed before service startup
Oslo::Coordination<||> -> Anchor['aodh::service::begin']
# all db settings should be applied and all packages should be installed
# before dbsync starts
Oslo::Db<||> -> Anchor['aodh::dbsync::begin']
# policy config should occur in the config block also.
Anchor['aodh::config::begin']
-> Openstacklib::Policy<| tag == 'aodh' |>
-> Anchor['aodh::config::end'] -> Anchor['aodh::config::end']
# On any uwsgi config change, we must restart Aodh API.
Anchor['aodh::config::begin'] Anchor['aodh::config::begin']
-> Aodh_api_uwsgi_config<||> -> Aodh_api_uwsgi_config<||>
~> Anchor['aodh::config::end'] -> Anchor['aodh::config::end']
# Installation or config changes will always restart services. # Installation or config changes will always restart services.
Anchor['aodh::install::end'] ~> Anchor['aodh::service::begin'] Anchor['aodh::install::end'] ~> Anchor['aodh::service::begin']

View File

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

View File

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