From fca0e2d42417460ccc616d4d6b5c1f126de893fd Mon Sep 17 00:00:00 2001 From: Tobias Urdin Date: Mon, 31 Aug 2020 00:05:47 +0200 Subject: [PATCH] Remove deprecated database_connection in init Change-Id: I92f04101059ae5711f91df8740141ad532bc053c --- manifests/db.pp | 14 +++++-------- manifests/init.pp | 20 +++---------------- ...e-deprecated-db-init-62110da4e2d86881.yaml | 7 +++++++ spec/classes/gnocchi_db_spec.rb | 2 +- 4 files changed, 16 insertions(+), 27 deletions(-) create mode 100644 releasenotes/notes/remove-deprecated-db-init-62110da4e2d86881.yaml diff --git a/manifests/db.pp b/manifests/db.pp index 01d6d8a4..80ebcc20 100644 --- a/manifests/db.pp +++ b/manifests/db.pp @@ -19,19 +19,15 @@ class gnocchi::db ( include gnocchi::deps - # NOTE(spredzy): In order to keep backward compatibility we rely on the pick function - # to use gnocchi:: if gnocchi::db:: isn't specified. - $database_connection_real = pick($::gnocchi::database_connection, $database_connection) - - validate_legacy(Oslo::Dbconn, 'validate_re', $database_connection_real, + validate_legacy(Oslo::Dbconn, 'validate_re', $database_connection, ['^(sqlite|mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?']) - if $database_connection_real { - case $database_connection_real { + if $database_connection { + case $database_connection { /^mysql(\+pymysql)?:\/\//: { require mysql::bindings require mysql::bindings::python - if $database_connection_real =~ /^mysql\+pymysql/ { + if $database_connection =~ /^mysql\+pymysql/ { $backend_package = $::gnocchi::params::pymysql_package_name } else { $backend_package = false @@ -58,7 +54,7 @@ class gnocchi::db ( } gnocchi_config { - 'indexer/url': value => $database_connection_real, secret => true; + 'indexer/url': value => $database_connection, secret => true; } # NOTE(tobasco): gnocchi-indexer-sqlalchemy not packaged in Ubuntu for Queens release. diff --git a/manifests/init.pp b/manifests/init.pp index d247e7ae..641911b2 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -17,27 +17,13 @@ # in the gnocchi config. # Defaults to false. # -# DEPRECATED PARAMETERS -# -# [*database_connection*] -# (optional) Connection url for the gnocchi database. -# Defaults to undef. -# class gnocchi ( - $package_ensure = 'present', - $coordination_url = $::os_service_default, - $purge_config = false, - # DEPRECATED PARAMETERS - $database_connection = undef, + $package_ensure = 'present', + $coordination_url = $::os_service_default, + $purge_config = false, ) inherits gnocchi::params { include gnocchi::deps - include gnocchi::db - - if $database_connection { - warning('The gnocchi::database_connection parameter is deprecated. \ -Use gnocchi::db::database_connection instead.') - } package { 'gnocchi': ensure => $package_ensure, diff --git a/releasenotes/notes/remove-deprecated-db-init-62110da4e2d86881.yaml b/releasenotes/notes/remove-deprecated-db-init-62110da4e2d86881.yaml new file mode 100644 index 00000000..362f8528 --- /dev/null +++ b/releasenotes/notes/remove-deprecated-db-init-62110da4e2d86881.yaml @@ -0,0 +1,7 @@ +--- +upgrade: + - | + The deprecated gnocchi::database_connection parameter is removed. + Use the gnocchi:db::database_connection parameter instead. + - | + Deployments now need to explicitly use the gnocchi::db class. \ No newline at end of file diff --git a/spec/classes/gnocchi_db_spec.rb b/spec/classes/gnocchi_db_spec.rb index 5a5b79bf..953c5901 100644 --- a/spec/classes/gnocchi_db_spec.rb +++ b/spec/classes/gnocchi_db_spec.rb @@ -24,7 +24,7 @@ describe 'gnocchi::db' do context 'with postgresql backend' do let :params do - { :database_connection => 'postgresql://gnocchi:gnocchi@localhost/gnocchi', } + { :database_connection => 'postgresql://gnocchi:gnocchi@localhost/gnocchi', } end it { should contain_package('python-psycopg2').with_ensure('present') }