From ec2b6434794f4ee194282df6464d07565b749f17 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Sat, 3 Aug 2024 03:24:30 +0900 Subject: [PATCH] db: Support connection_recycle_time option Change-Id: I47e1c76909e108b1ddfa365a913ed66565012387 --- manifests/db.pp | 56 +++++++------ ...nection_recycle_time-10b4ac5f7a8c63c1.yaml | 5 ++ spec/classes/placement_db_spec.rb | 79 ++++++++++--------- 3 files changed, 77 insertions(+), 63 deletions(-) create mode 100644 releasenotes/notes/database_connection_recycle_time-10b4ac5f7a8c63c1.yaml diff --git a/manifests/db.pp b/manifests/db.pp index 93887f3..b8273ef 100644 --- a/manifests/db.pp +++ b/manifests/db.pp @@ -16,6 +16,10 @@ # (Optional) Connection url to connect to placement slave database (read-only). # Defaults to $facts['os_service_default'] # +# [*database_connection_recycle_time*] +# Timeout when db connections should be reaped. +# (Optional) Defaults to $facts['os_service_default'] +# # [*database_mysql_sql_mode*] # (Optional) The SQL mode to be used for MySQL sessions. # Defaults to $facts['os_service_default'] @@ -55,36 +59,38 @@ # Defaults to $facts['os_service_default'] # class placement::db ( - $database_sqlite_synchronous = $facts['os_service_default'], - $database_connection = 'sqlite:////var/lib/placement/placement.sqlite', - $database_slave_connection = $facts['os_service_default'], - $database_mysql_sql_mode = $facts['os_service_default'], - $database_max_pool_size = $facts['os_service_default'], - $database_max_retries = $facts['os_service_default'], - $database_retry_interval = $facts['os_service_default'], - $database_max_overflow = $facts['os_service_default'], - $database_connection_debug = $facts['os_service_default'], - $database_connection_trace = $facts['os_service_default'], - $database_pool_timeout = $facts['os_service_default'], - $mysql_enable_ndb = $facts['os_service_default'], + $database_sqlite_synchronous = $facts['os_service_default'], + $database_connection = 'sqlite:////var/lib/placement/placement.sqlite', + $database_slave_connection = $facts['os_service_default'], + $database_connection_recycle_time = $facts['os_service_default'], + $database_mysql_sql_mode = $facts['os_service_default'], + $database_max_pool_size = $facts['os_service_default'], + $database_max_retries = $facts['os_service_default'], + $database_retry_interval = $facts['os_service_default'], + $database_max_overflow = $facts['os_service_default'], + $database_connection_debug = $facts['os_service_default'], + $database_connection_trace = $facts['os_service_default'], + $database_pool_timeout = $facts['os_service_default'], + $mysql_enable_ndb = $facts['os_service_default'], ) { include placement::deps oslo::db { 'placement_config': - config_group => 'placement_database', - sqlite_synchronous => $database_sqlite_synchronous, - connection => $database_connection, - slave_connection => $database_slave_connection, - mysql_sql_mode => $database_mysql_sql_mode, - max_pool_size => $database_max_pool_size, - max_retries => $database_max_retries, - retry_interval => $database_retry_interval, - max_overflow => $database_max_overflow, - connection_debug => $database_connection_debug, - connection_trace => $database_connection_trace, - pool_timeout => $database_pool_timeout, - mysql_enable_ndb => $mysql_enable_ndb, + config_group => 'placement_database', + sqlite_synchronous => $database_sqlite_synchronous, + connection => $database_connection, + slave_connection => $database_slave_connection, + connection_recycle_time => $database_connection_recycle_time, + mysql_sql_mode => $database_mysql_sql_mode, + max_pool_size => $database_max_pool_size, + max_retries => $database_max_retries, + retry_interval => $database_retry_interval, + max_overflow => $database_max_overflow, + connection_debug => $database_connection_debug, + connection_trace => $database_connection_trace, + pool_timeout => $database_pool_timeout, + mysql_enable_ndb => $mysql_enable_ndb, } # all db settings should be applied and all packages should be installed diff --git a/releasenotes/notes/database_connection_recycle_time-10b4ac5f7a8c63c1.yaml b/releasenotes/notes/database_connection_recycle_time-10b4ac5f7a8c63c1.yaml new file mode 100644 index 0000000..9c4af1d --- /dev/null +++ b/releasenotes/notes/database_connection_recycle_time-10b4ac5f7a8c63c1.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + The new ``placement::db::database_connection_recycle_time`` parameter has + been added. diff --git a/spec/classes/placement_db_spec.rb b/spec/classes/placement_db_spec.rb index 8dca783..30b39c1 100644 --- a/spec/classes/placement_db_spec.rb +++ b/spec/classes/placement_db_spec.rb @@ -8,37 +8,39 @@ describe 'placement::db' do } it { should contain_oslo__db('placement_config').with( - :config_group => 'placement_database', - :sqlite_synchronous => '', - :connection => 'sqlite:////var/lib/placement/placement.sqlite', - :slave_connection => '', - :mysql_sql_mode => '', - :max_pool_size => '', - :max_retries => '', - :retry_interval => '', - :max_overflow => '', - :connection_debug => '', - :connection_trace => '', - :pool_timeout => '', - :mysql_enable_ndb => '', + :config_group => 'placement_database', + :sqlite_synchronous => '', + :connection => 'sqlite:////var/lib/placement/placement.sqlite', + :slave_connection => '', + :connection_recycle_time => '', + :mysql_sql_mode => '', + :max_pool_size => '', + :max_retries => '', + :retry_interval => '', + :max_overflow => '', + :connection_debug => '', + :connection_trace => '', + :pool_timeout => '', + :mysql_enable_ndb => '', )} end context 'with specific parameters' do let :params do { - :database_sqlite_synchronous => true, - :database_connection => 'mysql+pymysql://placement:placement@localhost/placement', - :database_slave_connection => 'mysql+pymysql://placement2:placement2@localhost/placement2', - :database_mysql_sql_mode => 'strict_mode', - :database_max_pool_size => '8', - :database_max_retries => '4', - :database_retry_interval => '-1', - :database_max_overflow => '2', - :database_connection_debug => '100', - :database_connection_trace => true, - :database_pool_timeout => '10', - :mysql_enable_ndb => true, + :database_sqlite_synchronous => true, + :database_connection => 'mysql+pymysql://placement:placement@localhost/placement', + :database_slave_connection => 'mysql+pymysql://placement2:placement2@localhost/placement2', + :database_connection_recycle_time => '3601', + :database_mysql_sql_mode => 'strict_mode', + :database_max_pool_size => '8', + :database_max_retries => '4', + :database_retry_interval => '-1', + :database_max_overflow => '2', + :database_connection_debug => '100', + :database_connection_trace => true, + :database_pool_timeout => '10', + :mysql_enable_ndb => true, } end @@ -47,19 +49,20 @@ describe 'placement::db' do } it { should contain_oslo__db('placement_config').with( - :config_group => 'placement_database', - :sqlite_synchronous => true, - :connection => 'mysql+pymysql://placement:placement@localhost/placement', - :slave_connection => 'mysql+pymysql://placement2:placement2@localhost/placement2', - :mysql_sql_mode => 'strict_mode', - :max_pool_size => '8', - :max_retries => '4', - :retry_interval => '-1', - :max_overflow => '2', - :connection_debug => '100', - :connection_trace => true, - :pool_timeout => '10', - :mysql_enable_ndb => true, + :config_group => 'placement_database', + :sqlite_synchronous => true, + :connection => 'mysql+pymysql://placement:placement@localhost/placement', + :slave_connection => 'mysql+pymysql://placement2:placement2@localhost/placement2', + :connection_recycle_time => '3601', + :mysql_sql_mode => 'strict_mode', + :max_pool_size => '8', + :max_retries => '4', + :retry_interval => '-1', + :max_overflow => '2', + :connection_debug => '100', + :connection_trace => true, + :pool_timeout => '10', + :mysql_enable_ndb => true, )} end end