Add support for the oslo db_max_retries parameter

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

Change-Id: If29c9758aa901ccf836934f88c61ccb1f09205c1
Closes-Bug: 1579718
This commit is contained in:
ZhongShengping 2016-05-10 21:12:50 +08:00
parent 5836d3d382
commit 7e68c28e53
2 changed files with 12 additions and 1 deletions

View File

@ -33,6 +33,11 @@
# If set, use this value for max_overflow with sqlalchemy.
# (Optional) 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 mistral::db (
$database_connection = 'sqlite:////var/lib/mistral/mistral.sqlite',
$database_idle_timeout = $::os_service_default,
@ -41,6 +46,7 @@ class mistral::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,
) {
# NOTE(spredzy): In order to keep backward compatibility we rely on the pick function
@ -64,6 +70,7 @@ class mistral::db (
max_retries => $database_max_retries_real,
retry_interval => $database_retry_interval_real,
max_overflow => $database_max_overflow_real,
db_max_retries => $database_db_max_retries,
}
}

View File

@ -11,6 +11,7 @@ describe 'mistral::db' do
it { is_expected.to contain_mistral_config('database/min_pool_size').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_mistral_config('database/max_retries').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_mistral_config('database/retry_interval').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_mistral_config('database/db_max_retries').with_value('<SERVICE DEFAULT>') }
end
@ -20,7 +21,9 @@ describe 'mistral::db' do
:database_idle_timeout => '3601',
:database_min_pool_size => '2',
:database_max_retries => '11',
:database_retry_interval => '11', }
:database_retry_interval => '11',
:database_db_max_retries => '-1',
}
end
it { is_expected.to contain_mistral_config('database/connection').with_value('mysql+pymysql://mistral:mistral@localhost/mistral').with_secret(true) }
@ -28,6 +31,7 @@ describe 'mistral::db' do
it { is_expected.to contain_mistral_config('database/min_pool_size').with_value('2') }
it { is_expected.to contain_mistral_config('database/max_retries').with_value('11') }
it { is_expected.to contain_mistral_config('database/retry_interval').with_value('11') }
it { is_expected.to contain_mistral_config('database/db_max_retries').with_value('-1') }
end
context 'with postgresql backend' do