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: Ibb0875cb5064e79f049d312375899858e1d7eaae
Closes-Bug: 1579718
This commit is contained in:
ZhongShengping 2017-04-16 09:02:04 +08:00
parent 5f34c0f649
commit 5059bdf9a2
3 changed files with 16 additions and 0 deletions

View File

@ -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) Url used to connect to database.
# Defaults to "sqlite:////var/lib/tacker/tacker.sqlite".
@ -34,6 +39,7 @@
# Defaults to $::os_service_default
#
class tacker::db (
$database_db_max_retries = $::os_service_default,
$database_connection = 'sqlite:////var/lib/tacker/tacker.sqlite',
$database_idle_timeout = $::os_service_default,
$database_min_pool_size = $::os_service_default,
@ -49,6 +55,7 @@ class tacker::db (
'^(sqlite|mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
oslo::db { 'tacker_config':
db_max_retries => $database_db_max_retries,
connection => $database_connection,
idle_timeout => $database_idle_timeout,
min_pool_size => $database_min_pool_size,

View File

@ -0,0 +1,6 @@
---
features:
- Add new option tacker::db::database_db_max_retries.
The database_db_max_retries parameter regulates the
number of reconnection attempts performed after an
error raised rather than at startup.

View File

@ -5,6 +5,7 @@ describe 'tacker::db' do
shared_examples 'tacker::db' do
context 'with default parameters' do
it { is_expected.to contain_oslo__db('tacker_config').with(
:db_max_retries => '<SERVICE DEFAULT>',
:connection => 'sqlite:////var/lib/tacker/tacker.sqlite',
:idle_timeout => '<SERVICE DEFAULT>',
:min_pool_size => '<SERVICE DEFAULT>',
@ -21,6 +22,7 @@ describe 'tacker::db' do
:database_idle_timeout => '3601',
:database_min_pool_size => '2',
:database_max_retries => '11',
:database_db_max_retries => '-1',
:database_retry_interval => '11',
:database_max_pool_size => '11',
:database_max_overflow => '21',
@ -33,6 +35,7 @@ describe 'tacker::db' do
:min_pool_size => '2',
:max_pool_size => '11',
:max_retries => '11',
:db_max_retries => '-1',
:retry_interval => '11',
:max_overflow => '21',
)}