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: I6a4c65e81b97235d0ce8a142245927c92ab6e48d
This commit is contained in:
Takashi Kajinami 2024-03-04 09:48:38 +09:00
parent 0dcda53bb3
commit 8b3054a13f
6 changed files with 27 additions and 15 deletions

View File

@ -584,6 +584,12 @@ enabled_backends instead.')
hasrestart => true,
tag => 'glance-service',
}
# On any paste-api.ini config change, we must restart Glance API.
Glance_api_paste_ini<||> ~> Service['glance-api']
# On any uwsgi config change, we must restart Glance API.
Glance_api_uwsgi_config<||> ~> Service['glance-api']
} elsif $service_name == 'httpd' {
service { 'glance-api':
ensure => 'stopped',
@ -595,6 +601,10 @@ enabled_backends instead.')
# we need to make sure glance-api/eventlet is stopped before trying to start apache
Service['glance-api'] -> Service[$service_name]
# On any paste-api.ini config change, we must restart Glance API.
Glance_api_paste_ini<||> ~> Service['glance-api']
} else {
fail("Invalid service_name. ${::glance::params::api_service_name} for \
running as a standalone service, or httpd for being run by a httpd server")

View File

@ -278,5 +278,7 @@ class glance::api::authtoken(
service_token_roles_required => $service_token_roles_required,
service_type => $service_type,
interface => $interface;
}
}
Keystone::Resource::Authtoken['glance_api_config'] -> Anchor['glance::config::end']
}

View File

@ -68,4 +68,8 @@ class glance::api::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['glance_api_config'] -> Anchor['glance::dbsync::begin']
}

View File

@ -24,19 +24,13 @@ class glance::deps {
~> Service<| tag == 'glance-service' |>
~> anchor { 'glance::service::end': }
# all db settings should be applied and all packages should be installed
# before dbsync starts
Oslo::Db<||> -> Anchor['glance::dbsync::begin']
# policy config should occur in the config block also.
Anchor['glance::config::begin']
-> Openstacklib::Policy<| tag == 'glance' |>
-> Anchor['glance::config::end']
# On any uwsgi config change, we must restart Glance API.
Anchor['glance::config::begin']
-> Glance_api_uwsgi_config<||>
~> Anchor['glance::config::end']
-> Anchor['glance::config::end']
Anchor['glance::config::begin']
-> Glance_api_paste_ini<||>
-> Anchor['glance::config::end']
# We need openstackclient before marking service end so that glance
# will have clients available to create resources. This tag handles the
@ -46,7 +40,6 @@ class glance::deps {
-> Anchor['glance::service::end']
# All other inifile providers need to be processed in the config block
Anchor['glance::config::begin'] -> Glance_api_paste_ini<||> ~> Anchor['glance::config::end']
Anchor['glance::config::begin'] -> Glance_image_import_config<||> ~> Anchor['glance::config::end']
Anchor['glance::config::begin'] -> Glance_swift_config<||> ~> Anchor['glance::config::end']
Anchor['glance::config::begin'] -> Glance_rootwrap_config<||> ~> Anchor['glance::config::end']

View File

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

View File

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