Install python-redis when coordination is set

Without this redis can be missing when needed and cause
metricd to go nuts.

Change-Id: I5aa394f25f8c7b0f733868eb4389acda26333132
This commit is contained in:
Pradeep Kilambi 2017-03-03 11:29:37 -05:00
parent ea7c395af4
commit c0f0622e1d
4 changed files with 34 additions and 3 deletions

View File

@ -23,6 +23,7 @@ class gnocchi::params {
$gnocchi_wsgi_script_source = '/usr/lib/python2.7/site-packages/gnocchi/rest/app.wsgi'
$pymysql_package_name = undef
$cradox_package_name = 'python2-cradox'
$redis_package_name = 'python-redis'
}
'Debian': {
$sqlite_package_name = 'python-pysqlite2'
@ -37,6 +38,7 @@ class gnocchi::params {
$gnocchi_wsgi_script_path = '/usr/lib/cgi-bin/gnocchi'
$gnocchi_wsgi_script_source = '/usr/share/gnocchi-common/app.wsgi'
$pymysql_package_name = 'python-pymysql'
$redis_package_name = 'python-redis'
$cradox_package_name = undef
}
default: {

View File

@ -32,8 +32,17 @@ class gnocchi::storage(
include ::gnocchi::deps
gnocchi_config {
'storage/coordination_url' : value => $coordination_url;
}
if $coordination_url {
gnocchi_config {
'storage/coordination_url' : value => $coordination_url;
}
if ($coordination_url =~ /^redis/ ) {
ensure_resource('package', 'python-redis', {
name => $::gnocchi::params::redis_package_name,
tag => 'openstack',
})
}
}
}

View File

@ -0,0 +1,4 @@
---
fixes:
- Install redis when coordination is set in gnocchi storage.
Otherwise metricd will go creazy and throw exceptions.

View File

@ -19,6 +19,13 @@ describe 'gnocchi::storage' do
it 'configures backend_url' do
is_expected.to contain_gnocchi_config('storage/coordination_url').with_value('redis://localhost:6379')
end
it 'installs python-redis package' do
is_expected.to contain_package(platform_params[:redis_package_name]).with(
:name => platform_params[:redis_package_name],
:tag => 'openstack'
)
end
end
end
@ -30,6 +37,15 @@ describe 'gnocchi::storage' do
facts.merge!(OSDefaults.get_facts())
end
let(:platform_params) do
case facts[:osfamily]
when 'Debian'
{ :redis_package_name => 'python-redis' }
when 'RedHat'
{ :redis_package_name => 'python-redis' }
end
end
it_behaves_like 'gnocchi-storage'
end
end