Add support for db_max_retries param

The db_max_retries parameter regulates the number of reconnection
attempts performed after an error raised rather than at startup.

Closes-Bug: 1579718
Change-Id: Iedc16e888196df6d22de95d9e8c5e53eecd467f5
This commit is contained in:
Giulio Fidente
2016-05-09 13:12:43 +02:00
parent f8ea995958
commit 15890b4569
2 changed files with 11 additions and 1 deletions

View File

@@ -4,6 +4,11 @@
#
# === Parameters
#
# [*database_db_max_retries*]
# Maximum retries in case of connection error or deadlock error before
# error is raised. Set to -1 to specify an infinite retry count.
# (Optional) Defaults to $::os_service_default
#
# [*database_connection*]
# Url used to connect to database.
# (Optional) Defaults to 'sqlite:////var/lib/keystone/keystone.sqlite'.
@@ -34,6 +39,7 @@
# (Optional) Defaults to $::os_service_default
#
class keystone::db (
$database_db_max_retries = $::os_service_default,
$database_connection = 'sqlite:////var/lib/keystone/keystone.sqlite',
$database_idle_timeout = $::os_service_default,
$database_min_pool_size = $::os_service_default,
@@ -59,6 +65,7 @@ class keystone::db (
'^(sqlite|mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
oslo::db { 'keystone_config':
db_max_retries => $database_db_max_retries,
connection => $database_connection_real,
idle_timeout => $database_idle_timeout_real,
min_pool_size => $database_min_pool_size_real,

View File

@@ -6,6 +6,7 @@ describe 'keystone::db' do
context 'with default parameters' do
it { is_expected.to contain_keystone_config('database/db_max_retries').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_keystone_config('database/connection').with_value('sqlite:////var/lib/keystone/keystone.sqlite').with_secret(true) }
it { is_expected.to contain_keystone_config('database/idle_timeout').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_keystone_config('database/min_pool_size').with_value('<SERVICE DEFAULT>') }
@@ -18,7 +19,8 @@ describe 'keystone::db' do
context 'with specific parameters' do
let :params do
{ :database_connection => 'mysql+pymysql://keystone:keystone@localhost/keystone',
{ :database_db_max_retries => '-1',
:database_connection => 'mysql+pymysql://keystone:keystone@localhost/keystone',
:database_idle_timeout => '3601',
:database_min_pool_size => '2',
:database_max_pool_size => '21',
@@ -27,6 +29,7 @@ describe 'keystone::db' do
:database_retry_interval => '11', }
end
it { is_expected.to contain_keystone_config('database/db_max_retries').with_value('-1') }
it { is_expected.to contain_keystone_config('database/connection').with_value('mysql+pymysql://keystone:keystone@localhost/keystone').with_secret(true) }
it { is_expected.to contain_keystone_config('database/idle_timeout').with_value('3601') }
it { is_expected.to contain_keystone_config('database/min_pool_size').with_value('2') }