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: Id4916244bdf4cd4ff2b45a45ec3e25fb0d115249
This commit is contained in:
Takashi Kajinami 2024-03-05 10:34:48 +09:00
parent 332fb89413
commit b47116d7aa
6 changed files with 30 additions and 21 deletions

View File

@ -218,6 +218,11 @@ class nova::api(
'DEFAULT/enabled_apis': value => join(any2array($enabled_apis), ',');
}
$service_enabled = $enabled
if $manage_service {
Nova_api_paste_ini<||> ~> Service['nova-api']
Nova_api_uwsgi_config<||> ~> Service['nova-api']
}
} elsif $service_name == 'httpd' {
nova_config {
'DEFAULT/enabled_apis': ensure => absent;
@ -238,6 +243,8 @@ class nova::api(
if $metadata_service_name {
Service['nova-api-metadata'] -> Service[$service_name]
}
Nova_api_paste_ini<||> ~> Service[$service_name]
}
} else {
fail("Invalid service_name. Either nova-api/openstack-nova-api for running \
@ -253,6 +260,9 @@ as a standalone service, or httpd for being run by a httpd server")
}
if $metadata_service_name {
if $manage_service {
Nova_api_metadata_uwsgi_config<||> ~> Service['nova-api-metadata']
}
nova::generic_service { 'api-metadata':
enabled => $service_enabled,
manage_service => $manage_service,

View File

@ -243,4 +243,8 @@ class nova::cache (
hashclient_retry_delay => $hashclient_retry_delay,
dead_timeout => $dead_timeout,
}
# all cache settings should be applied and all packages should be installed
# before service startup
Oslo::Cache['nova_config'] -> Anchor['nova::service::begin']
}

View File

@ -145,4 +145,10 @@ class nova::db (
max_overflow => $api_database_max_overflow,
pool_timeout => $api_database_pool_timeout,
}
# all db settings should be applied and all packages should be installed
# before dbsync starts
Oslo::Db['nova_config'] -> Anchor['nova::dbsync::begin']
Oslo::Db['api_database'] -> Anchor['nova::dbsync::begin']
Oslo::Db['api_database'] -> Anchor['nova::dbsync_api::begin']
}

View File

@ -24,30 +24,21 @@ class nova::deps {
~> Service<| tag == 'nova-service' |>
~> anchor { 'nova::service::end': }
# paste-api.ini config should occur in the config block also.
Anchor['nova::config::begin']
-> Nova_api_paste_ini<||>
~> Anchor['nova::config::end']
-> Anchor['nova::config::end']
# rootwrap config should occur in the config block also.
Anchor['nova::config::begin']
-> Nova_rootwrap_config<||>
~> Anchor['nova::config::end']
# policy config should occur in the config block also.
Anchor['nova::config::begin']
-> Openstacklib::Policy<| tag == 'nova' |>
-> Anchor['nova::config::end']
# On any uwsgi config change, we must restart Nova APIs.
Anchor['nova::config::begin']
-> Nova_api_uwsgi_config<||>
~> Anchor['nova::config::end']
-> Anchor['nova::config::end']
Anchor['nova::config::begin']
-> Nova_api_metadata_uwsgi_config<||>
~> Anchor['nova::config::end']
-> Anchor['nova::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
@ -84,15 +75,6 @@ class nova::deps {
Anchor['nova::config::begin'] -> Virtstoraged_config<||> -> Anchor['nova::config::end']
Anchor['nova::config::begin'] -> Qemu_config<||> -> Anchor['nova::config::end']
# all cache settings should be applied and all packages should be installed
# before service startup
Oslo::Cache<||> -> Anchor['nova::service::begin']
# all db settings should be applied and all packages should be installed
# before dbsync starts
Oslo::Db<||> -> Anchor['nova::dbsync::begin']
Oslo::Db<||> -> Anchor['nova::dbsync_api::begin']
# Installation or config changes will always restart services.
Anchor['nova::install::end'] ~> Anchor['nova::service::begin']
Anchor['nova::config::end'] ~> Anchor['nova::service::begin']

View File

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

View File

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