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: I4ebdf862e39b05bf28805052144b7dbad42a15de
Closes-Bug: 1579718
This commit is contained in:
ZhongShengping 2016-05-18 10:40:52 +08:00
parent e941ab51fa
commit 6531e716b3
2 changed files with 24 additions and 14 deletions

View File

@ -5,33 +5,38 @@
# === Parameters
#
# [*database_connection*]
# Url used to connect to database.
# (Optional) Defaults to "mysql://magnum:magnum@localhost:3306/magnum".
# (Optional) Url used to connect to database.
# Defaults to "mysql://magnum:magnum@localhost:3306/magnum".
#
# [*database_idle_timeout*]
# Timeout when db connections should be reaped.
# (Optional) Defaults to $::os_service_default
# (Optional) Timeout when db connections should be reaped.
# Defaults to $::os_service_default
#
# [*database_max_retries*]
# Maximum number of database connection retries during startup.
# (Optional) Maximum number of database connection retries during startup.
# Setting -1 implies an infinite retry count.
# (Optional) Defaults to $::os_service_default
# Defaults to $::os_service_default
#
# [*database_retry_interval*]
# Interval between retries of opening a database connection.
# (Optional) Defaults to $::os_service_default
# (Optional) Interval between retries of opening a database connection.
# Defaults to $::os_service_default
#
# [*database_min_pool_size*]
# Minimum number of SQL connections to keep open in a pool.
# (Optional) Defaults to $::os_service_default
# (Optional) Minimum number of SQL connections to keep open in a pool.
# Defaults to $::os_service_default
#
# [*database_max_pool_size*]
# Maximum number of SQL connections to keep open in a pool.
# (Optional) Defaults to $::os_service_default
# (Optional) Maximum number of SQL connections to keep open in a pool.
# Defaults to $::os_service_default
#
# [*database_max_overflow*]
# If set, use this value for max_overflow with sqlalchemy.
# (Optional) Defaults to $::os_service_default
# (Optional) If set, use this value for max_overflow with sqlalchemy.
# Defaults to $::os_service_default
#
# [*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
#
class magnum::db (
$database_connection = 'mysql://magnum:magnum@localhost:3306/magnum',
@ -41,6 +46,7 @@ class magnum::db (
$database_max_retries = $::os_service_default,
$database_retry_interval = $::os_service_default,
$database_max_overflow = $::os_service_default,
$database_db_max_retries = $::os_service_default,
) {
validate_re($database_connection,
@ -54,6 +60,7 @@ class magnum::db (
max_retries => $database_max_retries,
retry_interval => $database_retry_interval,
max_overflow => $database_max_overflow,
db_max_retries => $database_db_max_retries,
}
}

View File

@ -11,6 +11,7 @@ describe 'magnum::db' do
it { is_expected.to contain_magnum_config('database/retry_interval').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_magnum_config('database/max_pool_size').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_magnum_config('database/max_overflow').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_magnum_config('database/db_max_retries').with_value('<SERVICE DEFAULT>') }
end
context 'with specific parameters' do
@ -22,6 +23,7 @@ describe 'magnum::db' do
:database_retry_interval => '11',
:database_max_pool_size => '11',
:database_max_overflow => '21',
:database_db_max_retries => '-1',
}
end
@ -32,6 +34,7 @@ describe 'magnum::db' do
it { is_expected.to contain_magnum_config('database/retry_interval').with_value('11') }
it { is_expected.to contain_magnum_config('database/max_pool_size').with_value('11') }
it { is_expected.to contain_magnum_config('database/max_overflow').with_value('21') }
it { is_expected.to contain_magnum_config('database/db_max_retries').with_value('-1') }
end
context 'with postgresql backend' do