Skip to content

Commit

Permalink
Remove $jira::use_connection_pooling and use a common template for db…
Browse files Browse the repository at this point in the history
…config.xml

This removes the use_connection_pooling parameter since for most
databases, it does nothing useful anyway, and with PostgreSQL it
should always be enabled.
  • Loading branch information
oranenj committed Apr 13, 2021
1 parent 1c183ee commit 22d7269
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 146 deletions.
50 changes: 33 additions & 17 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,41 @@
group => $jira::group,
}

if $jira::validation_query == undef {
$validation_query = $jira::db ? {
'postgresql' => 'select version();',
'mysql' => 'select 1',
'oracle' => 'select 1 from dual',
'sqlserver' => 'select 1',
'h2' => 'select 1',
}
$dbschema_default = $jira::db ? {
'postgresql' => 'public',
default => undef
}
if $jira::time_between_eviction_runs == undef {
$time_between_eviction_runs = $jira::db ? {
'postgresql' => '30000',
'mysql' => '300000',
'oracle' => '300000',
'sqlserver' => '300000',
'h2' => '5000',
}

# can't use pick_default: https://tickets.puppetlabs.com/browse/MODULES-11018
$dbschema = if $jira::dbschema { $jira::dbschema } else { $dbschema_default }

$validation_query_default = $jira::db ? {
'postgresql' => 'select version();',
'mysql' => 'select 1',
'oracle' => 'select 1 from dual',
'sqlserver' => 'select 1',
'h2' => 'select 1',
}

$validation_query = if $jira::validation_query { $jira::validation_query } else { $validation_query_default }

$time_between_eviction_runs_default = $jira::db ? {
'postgresql' => '30000',
'mysql' => '300000',
'oracle' => '300000',
'sqlserver' => '300000',
'h2' => '5000',
}

$time_between_eviction_runs = if $jira::time_between_eviction_runs { $jira::time_between_eviction_runs } else { $time_between_eviction_runs_default }

$validation_query_timeout_default = $jira::db ? {
'mysql' => 3,
default => undef,
}

$validation_query_timeout = if $jira::validation_query_timeout { $jira::validation_query_timeout } else { $validation_query_timeout_default }

file { "${jira::webappdir}/bin/user.sh":
content => template('jira/user.sh.erb'),
mode => '0755',
Expand All @@ -56,7 +72,7 @@
}

-> file { "${jira::homedir}/dbconfig.xml":
content => template("jira/dbconfig.${jira::db}.xml.erb"),
content => epp('jira/dbconfig.xml.epp'),
mode => '0600',
require => [Class['jira::install'],File[$jira::homedir]],
notify => Class['jira::service'],
Expand Down
5 changes: 2 additions & 3 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,19 @@
Optional[String] $dbtype = undef,
Optional[String] $dburl = undef,
$poolsize = '20',
$dbschema = 'public',
$dbschema = undef,
# MySQL Connector Settings
$mysql_connector_manage = true,
$mysql_connector_version = '5.1.34',
$mysql_connector_product = 'mysql-connector-java',
$mysql_connector_format = 'tar.gz',
Stdlib::Absolutepath $mysql_connector_install = '/opt/MySQL-connector',
Stdlib::HTTPUrl $mysql_connector_url = 'https://dev.mysql.com/get/Downloads/Connector-J',
# Configure database settings if you are pooling connections
$enable_connection_pooling = false,
$pool_min_size = 20,
$pool_max_size = 20,
$pool_max_wait = 30000,
$validation_query = undef,
Optional[Integer[0]] $validation_query_timeout = undef,
$min_evictable_idle_time = 60000,
$time_between_eviction_runs = undef,
$pool_max_idle = 20,
Expand Down
23 changes: 0 additions & 23 deletions templates/dbconfig.h2.xml.erb

This file was deleted.

26 changes: 0 additions & 26 deletions templates/dbconfig.mysql.xml.erb

This file was deleted.

24 changes: 0 additions & 24 deletions templates/dbconfig.oracle.xml.erb

This file was deleted.

28 changes: 0 additions & 28 deletions templates/dbconfig.postgresql.xml.erb

This file was deleted.

25 changes: 0 additions & 25 deletions templates/dbconfig.sqlserver.xml.erb

This file was deleted.

32 changes: 32 additions & 0 deletions templates/dbconfig.xml.epp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>

<%# Some default are set in jira::config based on DB -%>
<jira-database-config>
<name>defaultDS</name>
<delegator-name>default</delegator-name>
<database-type><%= $jira::dbtype_real %></database-type>
<% if $jira::config::dbschema { -%>
<schema-name><%= $jira::config::dbschema %></schema-name>
<% } -%>
<jdbc-datasource>
<url><%= $jira::dburl_real %></url>
<driver-class><%= $jira::dbdriver_real %></driver-class>
<username><%= $jira::dbuser %></username>
<password><%= $jira::dbpassword %></password>
<pool-size><%= $jira::poolsize %></pool-size>
<pool-min-size><%= $jira::pool_min_size %></pool-min-size>
<pool-max-size><%= $jira::pool_max_size %></pool-max-size>
<pool-max-wait><%= $jira::pool_max_wait %></pool-max-wait>
<min-evictable-idle-time-millis><%= $jira::min_evictable_idle_time %></min-evictable-idle-time-millis>
<pool-max-idle><%= $jira::pool_max_idle %></pool-max-idle>
<pool-remove-abandoned><%= $jira::pool_remove_abandoned %></pool-remove-abandoned>
<pool-remove-abandoned-timeout><%= $jira::pool_remove_abandoned_timeout %></pool-remove-abandoned-timeout>
<pool-test-while-idle><%= $jira::pool_test_while_idle %></pool-test-while-idle>
<pool-test-on-borrow><%= $jira::pool_test_on_borrow %></pool-test-on-borrow>
<validation-query><%= $jira::config::validation_query %></validation-query>
<% if $jira::config::validation_query_timeout { -%>
<validation-query-timeout><%= $jira::config::validation_query_timeout %></validation-query-timeout>
<% } -%>
<time-between-eviction-runs-millis><%= $jira::config::time_between_eviction_runs %></time-between-eviction-runs-millis>
</jdbc-datasource>
</jira-database-config>

0 comments on commit 22d7269

Please sign in to comment.