From b47116d7aa2563c0040b880f45361346373d0348 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Tue, 5 Mar 2024 10:34:48 +0900 Subject: [PATCH] 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 --- manifests/api.pp | 10 ++++++++++ manifests/cache.pp | 4 ++++ manifests/db.pp | 6 ++++++ manifests/deps.pp | 24 +++--------------------- manifests/keystone/authtoken.pp | 2 ++ manifests/policy.pp | 5 +++++ 6 files changed, 30 insertions(+), 21 deletions(-) diff --git a/manifests/api.pp b/manifests/api.pp index 9dbbd1f87..1fca898ee 100644 --- a/manifests/api.pp +++ b/manifests/api.pp @@ -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, diff --git a/manifests/cache.pp b/manifests/cache.pp index 5707f9700..c8ec81cbc 100644 --- a/manifests/cache.pp +++ b/manifests/cache.pp @@ -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'] } diff --git a/manifests/db.pp b/manifests/db.pp index 89e662370..f7c2cef19 100644 --- a/manifests/db.pp +++ b/manifests/db.pp @@ -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'] } diff --git a/manifests/deps.pp b/manifests/deps.pp index 1f0149c6f..a3cddff4f 100644 --- a/manifests/deps.pp +++ b/manifests/deps.pp @@ -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'] diff --git a/manifests/keystone/authtoken.pp b/manifests/keystone/authtoken.pp index 1d3476ece..797ca5912 100644 --- a/manifests/keystone/authtoken.pp +++ b/manifests/keystone/authtoken.pp @@ -279,4 +279,6 @@ class nova::keystone::authtoken( service_type => $service_type, interface => $interface; } + + Keystone::Resource::Authtoken['nova_config'] -> Anchor['nova::config::end'] } diff --git a/manifests/policy.pp b/manifests/policy.pp index 522f0bc1e..f4d4c3583 100644 --- a/manifests/policy.pp +++ b/manifests/policy.pp @@ -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,