Skip to content

Commit

Permalink
Manage the maximum-pool-size configuration parameter in database.ini
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Ward committed May 2, 2016
1 parent 98821c2 commit 46f1b03
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 39 deletions.
4 changes: 4 additions & 0 deletions manifests/init.pp
Expand Up @@ -69,6 +69,8 @@
$temp_usage = $puppetdb::params::temp_usage,
$certificate_whitelist_file = $puppetdb::params::certificate_whitelist_file,
$certificate_whitelist = $puppetdb::params::certificate_whitelist,
$database_max_pool_size = $puppetdb::params::database_max_pool_size,
$read_database_max_pool_size = $puppetdb::params::read_database_max_pool_size,
) inherits puppetdb::params {

class { '::puppetdb::server':
Expand Down Expand Up @@ -136,6 +138,8 @@
temp_usage => $temp_usage,
certificate_whitelist_file => $certificate_whitelist_file,
certificate_whitelist => $certificate_whitelist,
database_max_pool_size => $database_max_pool_size,
read_database_max_pool_size => $read_database_max_pool_size,
}

if ($database == 'postgres') {
Expand Down
18 changes: 10 additions & 8 deletions manifests/params.pp
Expand Up @@ -20,14 +20,15 @@
$postgres_version = '9.4'

# The remaining database settings are not used for an embedded database
$database_host = 'localhost'
$database_port = '5432'
$database_name = 'puppetdb'
$database_username = 'puppetdb'
$database_password = 'puppetdb'
$database_ssl = undef
$jdbc_ssl_properties = ''
$database_validate = true
$database_host = 'localhost'
$database_port = '5432'
$database_name = 'puppetdb'
$database_username = 'puppetdb'
$database_password = 'puppetdb'
$database_ssl = undef
$jdbc_ssl_properties = ''
$database_validate = true
$database_max_pool_size = '25'

# These settings manage the various auto-deactivation and auto-purge settings
$node_ttl = '0s'
Expand Down Expand Up @@ -57,6 +58,7 @@
$read_conn_max_age = '60'
$read_conn_keep_alive = '45'
$read_conn_lifetime = '0'
$read_database_max_pool_size = '25'

$manage_firewall = true
$java_args = {}
Expand Down
34 changes: 19 additions & 15 deletions manifests/server.pp
Expand Up @@ -64,6 +64,8 @@
$temp_usage = $puppetdb::params::temp_usage,
$certificate_whitelist_file = $puppetdb::params::certificate_whitelist_file,
$certificate_whitelist = $puppetdb::params::certificate_whitelist,
$database_max_pool_size = $puppetdb::params::database_max_pool_size,
$read_database_max_pool_size = $puppetdb::params::read_database_max_pool_size,
) inherits puppetdb::params {
# deprecation warnings
if $database_ssl != undef {
Expand Down Expand Up @@ -151,6 +153,7 @@
database_password => $database_password,
database_name => $database_name,
database_ssl => $database_ssl,
database_max_pool_size => $database_max_pool_size,
jdbc_ssl_properties => $jdbc_ssl_properties,
database_validate => $database_validate,
database_embedded_path => $database_embedded_path,
Expand All @@ -167,21 +170,22 @@
}

class { 'puppetdb::server::read_database':
database => $read_database,
database_host => $read_database_host,
database_port => $read_database_port,
database_username => $read_database_username,
database_password => $read_database_password,
database_name => $read_database_name,
database_ssl => $read_database_ssl,
jdbc_ssl_properties => $read_database_jdbc_ssl_properties,
database_validate => $read_database_validate,
log_slow_statements => $read_log_slow_statements,
conn_max_age => $read_conn_max_age,
conn_keep_alive => $read_conn_keep_alive,
conn_lifetime => $read_conn_lifetime,
confdir => $confdir,
notify => Service[$puppetdb_service],
database => $read_database,
database_host => $read_database_host,
database_port => $read_database_port,
database_username => $read_database_username,
database_password => $read_database_password,
database_name => $read_database_name,
database_ssl => $read_database_ssl,
database_max_pool_size => $read_database_max_pool_size,
jdbc_ssl_properties => $read_database_jdbc_ssl_properties,
database_validate => $read_database_validate,
log_slow_statements => $read_log_slow_statements,
conn_max_age => $read_conn_max_age,
conn_keep_alive => $read_conn_keep_alive,
conn_lifetime => $read_conn_lifetime,
confdir => $confdir,
notify => Service[$puppetdb_service],
}

if str2bool($ssl_set_cert_paths) == true
Expand Down
6 changes: 6 additions & 0 deletions manifests/server/database.pp
Expand Up @@ -19,6 +19,7 @@
$conn_keep_alive = $puppetdb::params::conn_keep_alive,
$conn_lifetime = $puppetdb::params::conn_lifetime,
$confdir = $puppetdb::params::confdir,
$database_max_pool_size = $puppetdb::params::database_max_pool_size,
) inherits puppetdb::params {

if str2bool($database_validate) {
Expand Down Expand Up @@ -147,4 +148,9 @@
setting => 'conn-lifetime',
value => $conn_lifetime,
}

ini_setting { 'puppetdb_database_max_pool_size':
setting => 'maximum-pool-size',
value => $database_max_pool_size,
}
}
33 changes: 17 additions & 16 deletions manifests/server/read_database.pp
@@ -1,21 +1,22 @@
# PRIVATE CLASS - do not use directly
class puppetdb::server::read_database (
$database = $puppetdb::params::read_database,
$database_host = $puppetdb::params::read_database_host,
$database_port = $puppetdb::params::read_database_port,
$database_username = $puppetdb::params::read_database_username,
$database_password = $puppetdb::params::read_database_password,
$database_name = $puppetdb::params::read_database_name,
$database_ssl = $puppetdb::params::read_database_ssl,
$jdbc_ssl_properties = $puppetdb::params::read_database_jdbc_ssl_properties,
$database_validate = $puppetdb::params::read_database_validate,
$log_slow_statements = $puppetdb::params::read_log_slow_statements,
$conn_max_age = $puppetdb::params::read_conn_max_age,
$conn_keep_alive = $puppetdb::params::read_conn_keep_alive,
$conn_lifetime = $puppetdb::params::read_conn_lifetime,
$confdir = $puppetdb::params::confdir,
$puppetdb_user = $puppetdb::params::puppetdb_user,
$puppetdb_group = $puppetdb::params::puppetdb_group,
$database = $puppetdb::params::read_database,
$database_host = $puppetdb::params::read_database_host,
$database_port = $puppetdb::params::read_database_port,
$database_username = $puppetdb::params::read_database_username,
$database_password = $puppetdb::params::read_database_password,
$database_name = $puppetdb::params::read_database_name,
$database_ssl = $puppetdb::params::read_database_ssl,
$jdbc_ssl_properties = $puppetdb::params::read_database_jdbc_ssl_properties,
$database_validate = $puppetdb::params::read_database_validate,
$log_slow_statements = $puppetdb::params::read_log_slow_statements,
$conn_max_age = $puppetdb::params::read_conn_max_age,
$conn_keep_alive = $puppetdb::params::read_conn_keep_alive,
$conn_lifetime = $puppetdb::params::read_conn_lifetime,
$confdir = $puppetdb::params::confdir,
$puppetdb_user = $puppetdb::params::puppetdb_user,
$puppetdb_group = $puppetdb::params::puppetdb_group,
$database_max_pool_size = $puppetdb::params::read_database_max_pool_size,
) inherits puppetdb::params {

# Only add the read database configuration if database host is defined.
Expand Down
16 changes: 16 additions & 0 deletions spec/unit/classes/server/database_ini_spec.rb
Expand Up @@ -118,6 +118,14 @@
'setting' => 'conn-lifetime',
'value' => '0'
)}
it { should contain_ini_setting('puppetdb_database_max_pool_size').
with(
'ensure' => 'present',
'path' => '/etc/puppetlabs/puppetdb/conf.d/database.ini',
'section' => 'database',
'setting' => 'maximum-pool-size',
'value' => '25'
)}
end

describe 'when using a legacy PuppetDB version' do
Expand Down Expand Up @@ -226,6 +234,14 @@
'setting' => 'conn-lifetime',
'value' => '0'
)}
it { should contain_ini_setting('puppetdb_database_max_pool_size').
with(
'ensure' => 'present',
'path' => '/etc/puppetdb/conf.d/database.ini',
'section' => 'database',
'setting' => 'maximum-pool-size',
'value' => '25'
)}
end

describe 'when overriding database_path for embedded' do
Expand Down

0 comments on commit 46f1b03

Please sign in to comment.