From a06158ff358061854c5de8709fd2dbd9ac805b0d Mon Sep 17 00:00:00 2001 From: Carlos Camacho Date: Mon, 9 May 2016 15:02:37 +0200 Subject: [PATCH] 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: Iaf0d5ada30e0ea57d454ab1850cc61ee658cef64 Closes-Bug: 1579718 Co-Authored-By: Giulio Fidende --- manifests/db.pp | 7 +++++++ spec/classes/aodh_db_spec.rb | 7 ++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/manifests/db.pp b/manifests/db.pp index 07b42417..3f157eca 100644 --- a/manifests/db.pp +++ b/manifests/db.pp @@ -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*] # Url used to connect to database. # (Optional) Defaults to "sqlite:////var/lib/aodh/aodh.sqlite". @@ -34,6 +39,7 @@ # (Optional) Defaults to 20. # class aodh::db ( + $database_db_max_retries = $::os_service_default, $database_connection = 'sqlite:////var/lib/aodh/aodh.sqlite', $database_idle_timeout = 3600, $database_min_pool_size = 1, @@ -52,6 +58,7 @@ class aodh::db ( $database_max_overflow_real = pick($::aodh::database_max_overflow, $database_max_overflow) oslo::db { 'aodh_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, diff --git a/spec/classes/aodh_db_spec.rb b/spec/classes/aodh_db_spec.rb index 2250580f..72b33de5 100644 --- a/spec/classes/aodh_db_spec.rb +++ b/spec/classes/aodh_db_spec.rb @@ -5,7 +5,7 @@ describe 'aodh::db' do shared_examples 'aodh::db' do context 'with default parameters' do - + it { is_expected.to contain_aodh_config('database/db_max_retries').with_value('') } it { is_expected.to contain_aodh_config('database/connection').with_value('sqlite:////var/lib/aodh/aodh.sqlite') } it { is_expected.to contain_aodh_config('database/idle_timeout').with_value('3600') } it { is_expected.to contain_aodh_config('database/min_pool_size').with_value('1') } @@ -16,14 +16,15 @@ describe 'aodh::db' do context 'with specific parameters' do let :params do - { :database_connection => 'mysql+pymysql://aodh:aodh@localhost/aodh', + { :database_db_max_retries => '-1', + :database_connection => 'mysql+pymysql://aodh:aodh@localhost/aodh', :database_idle_timeout => '3601', :database_min_pool_size => '2', :database_max_retries => '11', :database_retry_interval => '11', } end - + it { is_expected.to contain_aodh_config('database/db_max_retries').with_value('-1') } it { is_expected.to contain_aodh_config('database/connection').with_value('mysql+pymysql://aodh:aodh@localhost/aodh').with_secret(true) } it { is_expected.to contain_aodh_config('database/idle_timeout').with_value('3601') } it { is_expected.to contain_aodh_config('database/min_pool_size').with_value('2') }