From efe9727528603d90bed56b3b472f8bcb00377683 Mon Sep 17 00:00:00 2001 From: ZhongShengping Date: Tue, 18 Apr 2017 09:01:45 +0800 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: Ib3cfc7b27945389f523d7112d88462995e7416af Releated-Bug: #1579718 --- manifests/api/db.pp | 7 +++++++ .../notes/add_db_max_retries-81df176353e781a5.yaml | 6 ++++++ spec/classes/glance_api_db_spec.rb | 3 +++ 3 files changed, 16 insertions(+) create mode 100644 releasenotes/notes/add_db_max_retries-81df176353e781a5.yaml diff --git a/manifests/api/db.pp b/manifests/api/db.pp index 6d8e6b95..c7b5296e 100644 --- a/manifests/api/db.pp +++ b/manifests/api/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/glance/glance.sqlite'. @@ -34,6 +39,7 @@ # (Optional) Defaults to $::os_service_default. # class glance::api::db ( + $database_db_max_retries = $::os_service_default, $database_connection = 'sqlite:///var/lib/glance/glance.sqlite', $database_idle_timeout = $::os_service_default, $database_min_pool_size = $::os_service_default, @@ -59,6 +65,7 @@ class glance::api::db ( '^(sqlite|mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?') oslo::db { 'glance_api_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/releasenotes/notes/add_db_max_retries-81df176353e781a5.yaml b/releasenotes/notes/add_db_max_retries-81df176353e781a5.yaml new file mode 100644 index 00000000..e277667c --- /dev/null +++ b/releasenotes/notes/add_db_max_retries-81df176353e781a5.yaml @@ -0,0 +1,6 @@ +--- +features: + - Add new option glance::api::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. diff --git a/spec/classes/glance_api_db_spec.rb b/spec/classes/glance_api_db_spec.rb index 977f25e9..34140652 100644 --- a/spec/classes/glance_api_db_spec.rb +++ b/spec/classes/glance_api_db_spec.rb @@ -5,6 +5,7 @@ describe 'glance::api::db' do shared_examples 'glance::api::db' do context 'with default parameters' do it { is_expected.to contain_oslo__db('glance_api_config').with( + :db_max_retries => '', :connection => 'sqlite:///var/lib/glance/glance.sqlite', :idle_timeout => '', :min_pool_size => '', @@ -21,6 +22,7 @@ describe 'glance::api::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 'glance::api::db' do :min_pool_size => '2', :max_pool_size => '11', :max_retries => '11', + :db_max_retries => '-1', :retry_interval => '11', :max_overflow => '21', )}