Browse Source

Add config group support to oslo::db

We must support setting the oslo.db config
options in another section since services
like placement doesn't use the database section
but it's own placement_database section to
have backward compatibility from the split out
from nova.

[1] https://github.com/openstack/placement/blob/master/placement/conf/database.py#L50

Change-Id: I9f556c7839b3ea455d556d67d4ae2598a524b595
changes/72/631772/1
Tobias Urdin 3 years ago
parent
commit
2db95e6243
  1. 47
      manifests/db.pp
  2. 9
      releasenotes/notes/oslo-db-config-group-4502ce93406f57b4.yaml
  3. 37
      spec/defines/oslo_db_spec.rb

47
manifests/db.pp

@ -7,6 +7,12 @@
#
# === Parameters:
#
# [*config_group*]
# (Optional) The configuration group to set the database configuration in.
# Some OpenStack services might implement the oslo database options in another
# configuration group, this makes it available to set which one to use.
# Defaults to 'database'
#
# [*sqlite_synchronous*]
# (Optional) If True, SQLite uses synchronous mode (boolean value).
# Defaults to $::os_service_default
@ -101,6 +107,7 @@
# Defaults to $::os_service_default
#
define oslo::db(
$config_group = 'database',
$sqlite_synchronous = $::os_service_default,
$backend = $::os_service_default,
$manage_backend_package = true,
@ -169,26 +176,26 @@ define oslo::db(
}
$database_options = {
'database/sqlite_synchronous' => { value => $sqlite_synchronous },
'database/backend' => { value => $backend },
'database/connection' => { value => $connection, secret => true },
'database/slave_connection' => { value => $slave_connection, secret => true },
'database/mysql_sql_mode' => { value => $mysql_sql_mode },
'database/idle_timeout' => { value => $idle_timeout },
'database/min_pool_size' => { value => $min_pool_size },
'database/max_pool_size' => { value => $max_pool_size },
'database/max_retries' => { value => $max_retries },
'database/retry_interval' => { value => $retry_interval },
'database/max_overflow' => { value => $max_overflow },
'database/connection_debug' => { value => $connection_debug },
'database/connection_trace' => { value => $connection_trace },
'database/pool_timeout' => { value => $pool_timeout },
'database/use_db_reconnect' => { value => $use_db_reconnect },
'database/db_retry_interval' => { value => $db_retry_interval },
'database/db_inc_retry_interval' => { value => $db_inc_retry_interval },
'database/db_max_retry_interval' => { value => $db_max_retry_interval },
'database/db_max_retries' => { value => $db_max_retries },
'database/use_tpool' => { value => $use_tpool },
"${config_group}/sqlite_synchronous" => { value => $sqlite_synchronous },
"${config_group}/backend" => { value => $backend },
"${config_group}/connection" => { value => $connection, secret => true },
"${config_group}/slave_connection" => { value => $slave_connection, secret => true },
"${config_group}/mysql_sql_mode" => { value => $mysql_sql_mode },
"${config_group}/idle_timeout" => { value => $idle_timeout },
"${config_group}/min_pool_size" => { value => $min_pool_size },
"${config_group}/max_pool_size" => { value => $max_pool_size },
"${config_group}/max_retries" => { value => $max_retries },
"${config_group}/retry_interval" => { value => $retry_interval },
"${config_group}/max_overflow" => { value => $max_overflow },
"${config_group}/connection_debug" => { value => $connection_debug },
"${config_group}/connection_trace" => { value => $connection_trace },
"${config_group}/pool_timeout" => { value => $pool_timeout },
"${config_group}/use_db_reconnect" => { value => $use_db_reconnect },
"${config_group}/db_retry_interval" => { value => $db_retry_interval },
"${config_group}/db_inc_retry_interval" => { value => $db_inc_retry_interval },
"${config_group}/db_max_retry_interval" => { value => $db_max_retry_interval },
"${config_group}/db_max_retries" => { value => $db_max_retries },
"${config_group}/use_tpool" => { value => $use_tpool },
}
create_resources($name, $database_options)

9
releasenotes/notes/oslo-db-config-group-4502ce93406f57b4.yaml

@ -0,0 +1,9 @@
---
features:
- |
Added new parameter oslo::db::config_group that can be used to tell the
oslo::db resource in which config section in the configuration file it
should set the oslo.db specific database options. This doesn't change any
existing behavior and the default value is ``database``, this is to support
services like Placement that reads database config from ``placement_database``
group.

37
spec/defines/oslo_db_spec.rb

@ -34,6 +34,7 @@ describe 'oslo::db' do
context 'with overridden parameters' do
let :params do
{
:config_group => 'custom_group',
:backend => 'sqlalchemy',
:connection => 'mysql+pymysql://db:db@localhost/db',
:mysql_sql_mode => 'TRADITIONAL',
@ -56,24 +57,24 @@ describe 'oslo::db' do
end
it 'configures database parameters' do
is_expected.to contain_keystone_config('database/backend').with_value('sqlalchemy')
is_expected.to contain_keystone_config('database/connection').with_value('mysql+pymysql://db:db@localhost/db').with_secret(true)
is_expected.to contain_keystone_config('database/mysql_sql_mode').with_value('TRADITIONAL')
is_expected.to contain_keystone_config('database/idle_timeout').with_value('3601')
is_expected.to contain_keystone_config('database/min_pool_size').with_value('2')
is_expected.to contain_keystone_config('database/max_pool_size').with_value('100')
is_expected.to contain_keystone_config('database/max_retries').with_value('10')
is_expected.to contain_keystone_config('database/retry_interval').with_value('10')
is_expected.to contain_keystone_config('database/max_overflow').with_value('50')
is_expected.to contain_keystone_config('database/connection_debug').with_value('0')
is_expected.to contain_keystone_config('database/connection_trace').with_value(true)
is_expected.to contain_keystone_config('database/pool_timeout').with_value('10')
is_expected.to contain_keystone_config('database/use_db_reconnect').with_value(true)
is_expected.to contain_keystone_config('database/db_retry_interval').with_value('1')
is_expected.to contain_keystone_config('database/db_inc_retry_interval').with_value(true)
is_expected.to contain_keystone_config('database/db_max_retry_interval').with_value('10')
is_expected.to contain_keystone_config('database/db_max_retries').with_value('20')
is_expected.to contain_keystone_config('database/use_tpool').with_value(true)
is_expected.to contain_keystone_config('custom_group/backend').with_value('sqlalchemy')
is_expected.to contain_keystone_config('custom_group/connection').with_value('mysql+pymysql://db:db@localhost/db').with_secret(true)
is_expected.to contain_keystone_config('custom_group/mysql_sql_mode').with_value('TRADITIONAL')
is_expected.to contain_keystone_config('custom_group/idle_timeout').with_value('3601')
is_expected.to contain_keystone_config('custom_group/min_pool_size').with_value('2')
is_expected.to contain_keystone_config('custom_group/max_pool_size').with_value('100')
is_expected.to contain_keystone_config('custom_group/max_retries').with_value('10')
is_expected.to contain_keystone_config('custom_group/retry_interval').with_value('10')
is_expected.to contain_keystone_config('custom_group/max_overflow').with_value('50')
is_expected.to contain_keystone_config('custom_group/connection_debug').with_value('0')
is_expected.to contain_keystone_config('custom_group/connection_trace').with_value(true)
is_expected.to contain_keystone_config('custom_group/pool_timeout').with_value('10')
is_expected.to contain_keystone_config('custom_group/use_db_reconnect').with_value(true)
is_expected.to contain_keystone_config('custom_group/db_retry_interval').with_value('1')
is_expected.to contain_keystone_config('custom_group/db_inc_retry_interval').with_value(true)
is_expected.to contain_keystone_config('custom_group/db_max_retry_interval').with_value('10')
is_expected.to contain_keystone_config('custom_group/db_max_retries').with_value('20')
is_expected.to contain_keystone_config('custom_group/use_tpool').with_value(true)
end
end

Loading…
Cancel
Save