From 8b3054a13f6af070d627a019c9e1fd996fd1fd6a Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Mon, 4 Mar 2024 09:48:38 +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: I6a4c65e81b97235d0ce8a142245927c92ab6e48d --- manifests/api.pp | 10 ++++++++++ manifests/api/authtoken.pp | 4 +++- manifests/api/db.pp | 4 ++++ manifests/deps.pp | 17 +++++------------ manifests/policy.pp | 5 +++++ spec/classes/glance_policy_spec.rb | 2 -- 6 files changed, 27 insertions(+), 15 deletions(-) diff --git a/manifests/api.pp b/manifests/api.pp index 0ab1810a..bbc011a9 100644 --- a/manifests/api.pp +++ b/manifests/api.pp @@ -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") diff --git a/manifests/api/authtoken.pp b/manifests/api/authtoken.pp index 5a5fe40c..9db1ff89 100644 --- a/manifests/api/authtoken.pp +++ b/manifests/api/authtoken.pp @@ -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'] } diff --git a/manifests/api/db.pp b/manifests/api/db.pp index 3b24546c..095e1199 100644 --- a/manifests/api/db.pp +++ b/manifests/api/db.pp @@ -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'] } diff --git a/manifests/deps.pp b/manifests/deps.pp index ea5dc05d..f34fdfd5 100644 --- a/manifests/deps.pp +++ b/manifests/deps.pp @@ -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'] diff --git a/manifests/policy.pp b/manifests/policy.pp index 4a07575d..f42dbd10 100644 --- a/manifests/policy.pp +++ b/manifests/policy.pp @@ -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, diff --git a/spec/classes/glance_policy_spec.rb b/spec/classes/glance_policy_spec.rb index f5f96cc5..b875b1ee 100644 --- a/spec/classes/glance_policy_spec.rb +++ b/spec/classes/glance_policy_spec.rb @@ -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,