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: Ibb4ec743e772716153eefe07ac36b888c0fb2b84
This commit is contained in:
Takashi Kajinami 2024-03-04 10:05:53 +09:00
parent ca43069521
commit c23ad97125
5 changed files with 21 additions and 11 deletions

View File

@ -187,6 +187,12 @@ Use the enabled_provider_drivers parameter instead.')
hasrestart => true, hasrestart => true,
tag => 'octavia-service', tag => 'octavia-service',
} }
# On any api-paste.ini config change, we must restart Octavia API.
Octavia_api_paste_ini<||> ~> Service['octavia-api']
# On any uwsgi config change, we must restart Octavia API.
Octavia_api_uwsgi_config<||> ~> Service['octavia-api']
} elsif $service_name == 'httpd' { } elsif $service_name == 'httpd' {
service { 'octavia-api': service { 'octavia-api':
ensure => 'stopped', ensure => 'stopped',
@ -196,6 +202,10 @@ Use the enabled_provider_drivers parameter instead.')
} }
Service['octavia-api'] -> Service[$service_name] Service['octavia-api'] -> Service[$service_name]
Service<| title == 'httpd' |> { tag +> 'octavia-service' } Service<| title == 'httpd' |> { tag +> 'octavia-service' }
# On any api-paste.ini config change, we must restart Octavia API.
Octavia_api_paste_ini<||> ~> Service['octavia-api']
} else { } else {
fail("Invalid service_name. Either octavia-api/openstack-octavia-api for \ fail("Invalid service_name. Either octavia-api/openstack-octavia-api for \
running as a standalone service, or httpd for being run by a httpd server") running as a standalone service, or httpd for being run by a httpd server")

View File

@ -69,4 +69,7 @@ class octavia::db (
db_max_retries => $database_db_max_retries, db_max_retries => $database_db_max_retries,
} }
# all db settings should be applied and all packages should be installed
# before dbsync starts
Oslo::Db['octavia_config'] -> Anchor['octavia::dbsync::begin']
} }

View File

@ -27,19 +27,9 @@ class octavia::deps {
~> Service<| tag == 'octavia-service' |> ~> Service<| tag == 'octavia-service' |>
~> anchor { 'octavia::service::end': } ~> anchor { 'octavia::service::end': }
# policy config should occur in the config block also.
Anchor['octavia::config::begin']
-> Openstacklib::Policy<| tag == 'octavia' |>
-> Anchor['octavia::config::end']
# On any uwsgi config change, we must restart Octavia API.
Anchor['octavia::config::begin'] Anchor['octavia::config::begin']
-> Octavia_api_uwsgi_config<||> -> Octavia_api_uwsgi_config<||>
~> Anchor['octavia::config::end'] -> Anchor['octavia::config::end']
# all db settings should be applied and all packages should be installed
# before dbsync starts
Oslo::Db<||> -> Anchor['octavia::dbsync::begin']
# Installation or config changes will always restart services. # Installation or config changes will always restart services.
Anchor['octavia::install::end'] ~> Anchor['octavia::service::begin'] Anchor['octavia::install::end'] ~> Anchor['octavia::service::begin']

View File

@ -279,5 +279,7 @@ class octavia::keystone::authtoken(
service_type => $service_type, service_type => $service_type,
interface => $interface; interface => $interface;
} }
Keystone::Resource::Authtoken['octavia_config'] -> Anchor['octavia::config::end']
} }

View File

@ -70,6 +70,11 @@ class octavia::policy (
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['octavia::config::begin']
-> Openstacklib::Policy[$policy_path]
-> Anchor['octavia::config::end']
oslo::policy { 'octavia_config': oslo::policy { 'octavia_config':
enforce_scope => $enforce_scope, enforce_scope => $enforce_scope,
enforce_new_defaults => $enforce_new_defaults, enforce_new_defaults => $enforce_new_defaults,