Deprecate parameters under gnocchi::storage

coordination_url[1] and metric_processing_delay[2] under storage
section are both deprecated, so deprecate parameters under
gnocchi::storage and migrate these parameters to appropriate
classes, gnocchi and gnocchi::metricd .

[1] 70b9ca427b
[2] 72fdba704d
Change-Id: I88dff282df4ce477e543dd2fcf5052a9ac472b84
This commit is contained in:
Takashi Kajinami
2020-03-18 22:37:15 +09:00
parent 036d7b5fe2
commit 271ccb6103
6 changed files with 89 additions and 50 deletions

View File

@@ -12,6 +12,10 @@
# (optional) Connection url for the gnocchi database.
# Defaults to undef.
#
# [*coordination_url*]
# (optional) The url to use for distributed group membership coordination.
# Defaults to $::os_service_default.
#
# [*purge_config*]
# (optional) Whether to set only the specified config options
# in the gnocchi config.
@@ -20,6 +24,7 @@
class gnocchi (
$package_ensure = 'present',
$database_connection = undef,
$coordination_url = $::os_service_default,
$purge_config = false,
) inherits gnocchi::params {
@@ -36,4 +41,21 @@ class gnocchi (
purge => $purge_config,
}
$coordination_url_real = pick($::gnocchi::storage::coordination_url, $coordination_url)
$storage_package_ensure = pick($::gnocchi::storage::package_ensure, $package_ensure)
if $coordination_url_real {
gnocchi_config {
'DEFAULT/coordination_url' : value => $coordination_url_real;
}
if ($coordination_url_real =~ /^redis/ ) {
ensure_resource('package', 'python-redis', {
ensure => $storage_package_ensure,
name => $::gnocchi::params::redis_package_name,
tag => 'openstack',
})
}
}
}

View File

@@ -38,10 +38,12 @@ class gnocchi::metricd (
include gnocchi::deps
$metric_processing_delay_real = pick($::gnocchi::storage::metric_processing_delay, $metric_processing_delay)
gnocchi_config {
'metricd/workers': value => $workers;
'metricd/metric_cleanup_delay': value => $cleanup_delay;
'metricd/metric_processing_delay': value => $metric_processing_delay;
'metricd/workers': value => $workers;
'metricd/metric_cleanup_delay': value => $cleanup_delay;
'metricd/metric_processing_delay': value => $metric_processing_delay_real;
}
package { 'gnocchi-metricd':

View File

@@ -16,39 +16,41 @@
#
# == Parameters
#
# DEPRECATED PARAMETERS
#
# [*package_ensure*]
# (optional) ensure state for package.
# Defaults to 'present'
#
# [*coordination_url*]
# (optional) The url to use for distributed group membership coordination.
# Defaults to $::os_service_default.
# Defaults to undef
#
# [*metric_processing_delay*]
# (optional) Delay between processng metrics
# Defaults to $::os_service_default.
# Defaults to undef
#
class gnocchi::storage(
$package_ensure = 'present',
$coordination_url = $::os_service_default,
$metric_processing_delay = $::os_service_default,
# DEPRECATED PARAMETERS
$package_ensure = undef,
$coordination_url = undef,
$metric_processing_delay = undef,
) inherits gnocchi::params {
include gnocchi::deps
if $package_ensure {
warning('The gnocchi::storage::package_ensure parameter was deprecated. \
Use gnocchi::package_ensure instead')
}
if $coordination_url {
warning('The gnocchi::storage::coordination_url parameter was deprecated. \
Use gnocchi::coordination_url instead')
}
gnocchi_config {
'storage/coordination_url' : value => $coordination_url;
'storage/metric_processing_delay' : value => $metric_processing_delay;
}
if ($coordination_url =~ /^redis/ ) {
ensure_resource('package', 'python-redis', {
name => $::gnocchi::params::redis_package_name,
tag => 'openstack',
})
}
if $metric_processing_delay {
warning('The gnocchi::storage::metric_processing_delay parameter was deprecated. \
Use gnocchi::metricd::metric_processing_delay instead')
}
}

View File

@@ -0,0 +1,10 @@
---
deprecations:
- |
gnocchi::storage::coordination_url and gnocchi::storage::package_ensure
were deprecated because coordination_url in storage seciton was deprecated
in gnocchi. Use the parameters in gnocchi class.
- |
gnocchi::storage::metric_processing_dealy was deprecated because the
corresponding parameter under storage section was deprecated in gnocchi.
Use gnocchi::metricd::metric_processing_delay instead.

View File

@@ -27,6 +27,32 @@ describe 'gnocchi' do
})
end
it 'does not configure coordination_url' do
is_expected.not_to contain_gnocchi_config('DEFAUTL/coordination_url')
is_expected.not_to contain_package('python-redis')
end
end
context 'with overriden parameters' do
let :params do
{ :purge_config => true,
:coordination_url => 'redis://localhost:6379', }
end
it 'purges gnocchi config' do
is_expected.to contain_resources('gnocchi_config').with({
:purge => true
})
end
it 'cnfigures coordination' do
is_expected.to contain_gnocchi_config('DEFAULT/coordination_url').with_value('redis://localhost:6379')
is_expected.to contain_package('python-redis').with(
:name => platform_params[:redis_package_name],
:ensure => 'present',
:tag => 'openstack'
)
end
end
end
@@ -41,9 +67,13 @@ describe 'gnocchi' do
let(:platform_params) do
case facts[:osfamily]
when 'Debian'
{ :gnocchi_common_package => 'gnocchi-common' }
{ :gnocchi_common_package => 'gnocchi-common',
:redis_package_name => 'python3-redis'
}
when 'RedHat'
{ :gnocchi_common_package => 'gnocchi-common' }
{ :gnocchi_common_package => 'gnocchi-common',
:redis_package_name => 'python-redis'
}
end
end
it_behaves_like 'gnocchi'

View File

@@ -2,35 +2,8 @@ require 'spec_helper'
describe 'gnocchi::storage' do
let :params do
{ :package_ensure => 'latest' }
end
shared_examples_for 'gnocchi-storage' do
it { is_expected.to contain_class('gnocchi::deps') }
it { is_expected.to contain_class('gnocchi::params') }
context 'with coordination' do
before do
params.merge!({
:coordination_url => 'redis://localhost:6379',
:metric_processing_delay => 30,
})
end
it 'configures backend_url' do
is_expected.to contain_gnocchi_config('storage/coordination_url').with_value('redis://localhost:6379')
is_expected.to contain_gnocchi_config('storage/metric_processing_delay').with_value(30)
end
it 'installs python-redis package' do
is_expected.to contain_package('python-redis').with(
:name => platform_params[:redis_package_name],
:tag => 'openstack'
)
end
end
# Nothong to test
end
on_supported_os({