From 04f29cb088e7e1eadae5cb1834dab637d6c5b745 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Mon, 15 Nov 2021 10:06:44 +0900 Subject: [PATCH] Support more [metricd] parameters Change-Id: Iaa01939f5049c3816e08a774ea2fbef19d0e3cfc --- manifests/metricd.pp | 45 ++++++++++++++--- .../notes/metricd-opts-78c846cee9222e7d.yaml | 13 +++++ spec/classes/gnocchi_metricd_spec.rb | 49 ++++++++++--------- 3 files changed, 76 insertions(+), 31 deletions(-) create mode 100644 releasenotes/notes/metricd-opts-78c846cee9222e7d.yaml diff --git a/manifests/metricd.pp b/manifests/metricd.pp index d6b37743..ed9c45e1 100644 --- a/manifests/metricd.pp +++ b/manifests/metricd.pp @@ -14,34 +14,65 @@ # (optional) the number of workers. # Defaults to $::os_workers # -# [*cleanup_delay*] -# (optional) How many seconds to wait between -# cleaning of expired data. -# Defaults to $::os_service_default -# # [*metric_processing_delay*] # (optional) Delay between processng metrics # Defaults to $::os_service_default. # +# [*greedy*] +# (optional) Allow to bypass metric_processing_delay if metricd is noticed +# that messages are ready to be processed. +# Defaoults to $::os_service_default. +# +# [*metric_reporting_delay*] +# (optional) How many seocnds to wait between metric ingestion reporting. +# Defaults to $::os_service_default. +# +# [*metric_cleanup_delay*] +# (optional) How many seconds to wait between cleaning of expired data. +# Defaults to $::os_service_default. +# +# [*processing_replicas*] +# (optional) Number of workers tht share a task. +# Defaults to $::os_service_default. +# # [*manage_service*] # (optional) Whether the service should be managed by Puppet. # Defaults to true. # +# DEPRECATED PARAMETERS +# +# [*cleanup_delay*] +# (optional) How many seconds to wait between +# cleaning of expired data. +# Defaults to $::os_service_default +# class gnocchi::metricd ( $manage_service = true, $enabled = true, $workers = $::os_workers, $metric_processing_delay = $::os_service_default, - $cleanup_delay = $::os_service_default, + $greedy = $::os_service_default, + $metric_reporting_delay = $::os_service_default, + $metric_cleanup_delay = $::os_service_default, + $processing_replicas = $::os_service_default, $package_ensure = 'present', + # DEPRECATED PARAMETERS + $cleanup_delay = undef, ) inherits gnocchi::params { include gnocchi::deps + if $cleanup_delay != undef { + warning('The cleanup_delay parameter is deprecated. Use metric_cleanup_delay instead') + } + gnocchi_config { 'metricd/workers': value => $workers; - 'metricd/metric_cleanup_delay': value => $cleanup_delay; 'metricd/metric_processing_delay': value => $metric_processing_delay; + 'metricd/greedy': value => $greedy; + 'metricd/metric_reporting_delay': value => $metric_reporting_delay; + 'metricd/metric_cleanup_delay': value => pick($cleanup_delay, $metric_cleanup_delay); + 'metricd/processing_replicas': value => $processing_replicas; } package { 'gnocchi-metricd': diff --git a/releasenotes/notes/metricd-opts-78c846cee9222e7d.yaml b/releasenotes/notes/metricd-opts-78c846cee9222e7d.yaml new file mode 100644 index 00000000..cb8ba343 --- /dev/null +++ b/releasenotes/notes/metricd-opts-78c846cee9222e7d.yaml @@ -0,0 +1,13 @@ +--- +features: + - | + The following parameters have been added to the ``gnocchi::metricd`` class. + + - ``greedy`` + - ``metric_reporting_delay`` + - ``processing_replicas`` + +deprecations: + - | + The ``gnocchi::metricd::cleanup_delay`` parameter has been deprecated in + favor of the new ``gnocchi::metricd::metric_cleanup_delay`` parameter. diff --git a/spec/classes/gnocchi_metricd_spec.rb b/spec/classes/gnocchi_metricd_spec.rb index f1e35dec..4dd9c91f 100644 --- a/spec/classes/gnocchi_metricd_spec.rb +++ b/spec/classes/gnocchi_metricd_spec.rb @@ -18,6 +18,15 @@ describe 'gnocchi::metricd' do ) end + it 'configures the default value' do + is_expected.to contain_gnocchi_config('metricd/workers').with_value(4) + is_expected.to contain_gnocchi_config('metricd/metric_processing_delay').with_value('') + is_expected.to contain_gnocchi_config('metricd/greedy').with_value('') + is_expected.to contain_gnocchi_config('metricd/metric_reporting_delay').with_value('') + is_expected.to contain_gnocchi_config('metricd/metric_cleanup_delay').with_value('') + is_expected.to contain_gnocchi_config('metricd/processing_replicas').with_value('') + end + [{:enabled => true}, {:enabled => false}].each do |param_hash| context "when service should be #{param_hash[:enabled] ? 'enabled' : 'disabled'}" do before do @@ -56,33 +65,25 @@ describe 'gnocchi::metricd' do end end - context 'with workers set' do + context 'with parameters set' do before do params.merge!({ - :workers => 2 }) + :workers => 2, + :metric_processing_delay => 60, + :greedy => true, + :metric_reporting_delay => 120, + :metric_cleanup_delay => 300, + :processing_replicas => 3, + }) end - it 'configures gnocchi metricd worker value' do - is_expected.to contain_gnocchi_config('metricd/workers').with_value('2') - end - end - context 'with metric delay set' do - before do - params.merge!({ - :metric_processing_delay => 15 }) - end - it 'configures gnocchi metricd processing delay value' do - is_expected.to contain_gnocchi_config('metricd/metric_processing_delay').with_value('15') - end - end - - context 'with cleanup_delay set' do - before do - params.merge!({ - :cleanup_delay => 30 }) - end - it 'configures gnocchi metricd cleanup_delay value' do - is_expected.to contain_gnocchi_config('metricd/metric_cleanup_delay').with_value('30') + it 'configures the overridden value' do + is_expected.to contain_gnocchi_config('metricd/workers').with_value(2) + is_expected.to contain_gnocchi_config('metricd/metric_processing_delay').with_value(60) + is_expected.to contain_gnocchi_config('metricd/greedy').with_value(true) + is_expected.to contain_gnocchi_config('metricd/metric_reporting_delay').with_value(120) + is_expected.to contain_gnocchi_config('metricd/metric_cleanup_delay').with_value(300) + is_expected.to contain_gnocchi_config('metricd/processing_replicas').with_value(3) end end end @@ -92,7 +93,7 @@ describe 'gnocchi::metricd' do }).each do |os,facts| context "on #{os}" do let (:facts) do - facts.merge!(OSDefaults.get_facts()) + facts.merge!(OSDefaults.get_facts({ :os_workers => 4 })) end let(:platform_params) do