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. Change-Id: I55a5df7f6ba9cc2d62b745e027f3059b45061352 Closes-Bug: 1579718
This commit is contained in:
parent
e5f369e5a7
commit
0d4b0cc71f
@ -4,6 +4,11 @@
|
||||
#
|
||||
# == Parameters
|
||||
#
|
||||
# [*database_db_max_retries*]
|
||||
# (optional) Maximum retries in case of connection error or deadlock error
|
||||
# before error is raised. Set to -1 to specify an infinite retry count.
|
||||
# Defaults to $::os_service_default
|
||||
#
|
||||
# [*database_connection*]
|
||||
# (Optional) The connection string to use to connect to the database.
|
||||
# Defaults to 'mysql+pymysql://sahara:secrete@localhost:3306/sahara'
|
||||
@ -34,6 +39,7 @@
|
||||
# Defaults to $::os_service_default.
|
||||
#
|
||||
class sahara::db (
|
||||
$database_db_max_retries = $::os_service_default,
|
||||
$database_connection = 'mysql+pymysql://sahara:secrete@localhost:3306/sahara',
|
||||
$database_idle_timeout = $::os_service_default,
|
||||
$database_min_pool_size = $::os_service_default,
|
||||
@ -57,6 +63,7 @@ class sahara::db (
|
||||
'^(mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
|
||||
|
||||
oslo::db { 'sahara_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,
|
||||
|
@ -4,6 +4,7 @@ describe 'sahara::db' do
|
||||
|
||||
shared_examples 'sahara::db' do
|
||||
context 'with default parameters' do
|
||||
it { is_expected.to contain_sahara_config('database/db_max_retries').with_value('<SERVICE DEFAULT>') }
|
||||
it { is_expected.to contain_sahara_config('database/connection').with_value('mysql+pymysql://sahara:secrete@localhost:3306/sahara').with_secret(true) }
|
||||
it { is_expected.to contain_sahara_config('database/idle_timeout').with_value('<SERVICE DEFAULT>') }
|
||||
it { is_expected.to contain_sahara_config('database/min_pool_size').with_value('<SERVICE DEFAULT>') }
|
||||
@ -15,7 +16,8 @@ describe 'sahara::db' do
|
||||
|
||||
context 'with specific parameters' do
|
||||
let :params do
|
||||
{ :database_connection => 'mysql+pymysql://sahara:sahara@localhost/sahara',
|
||||
{ :database_db_max_retries => '-1',
|
||||
:database_connection => 'mysql+pymysql://sahara:sahara@localhost/sahara',
|
||||
:database_idle_timeout => '3601',
|
||||
:database_min_pool_size => '2',
|
||||
:database_max_retries => '11',
|
||||
@ -25,6 +27,7 @@ describe 'sahara::db' do
|
||||
}
|
||||
end
|
||||
|
||||
it { is_expected.to contain_sahara_config('database/db_max_retries').with_value('-1') }
|
||||
it { is_expected.to contain_sahara_config('database/connection').with_value('mysql+pymysql://sahara:sahara@localhost/sahara').with_secret(true) }
|
||||
it { is_expected.to contain_sahara_config('database/idle_timeout').with_value('3601') }
|
||||
it { is_expected.to contain_sahara_config('database/min_pool_size').with_value('2') }
|
||||
|
Loading…
Reference in New Issue
Block a user