Skip to content

Commit

Permalink
Configure recommended JDBC connection-properties by default
Browse files Browse the repository at this point in the history
For PostgreSQL only. Also fixes voxpupuli#380
  • Loading branch information
oranenj committed May 18, 2021
1 parent b395d31 commit a08f33a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
9 changes: 7 additions & 2 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,13 @@
$pool_test_while_idle = pick($jira::pool_test_while_idle, true)
$pool_test_on_borrow = pick($jira::pool_test_on_borrow, false)

# This is just for consistency
$connection_settings = $jira::connection_settings
# JIRA will complain if these aren't set for PostgreSQL (will work fine though)
# https://confluence.atlassian.com/jirakb/connection-problems-to-postgresql-result-in-stuck-threads-in-jira-1047534091.html
if $jira::db == 'postgresql' {
$connection_settings = pick($jira::connection_settings, 'tcpKeepAlive=true;socketTimeout=240')
} else {
$connection_settings = $jira::connection_settings
}

if $jira::db == 'mysql' {
$validation_query_timeout = pick($jira::validation_query_timeout, 3)
Expand Down
4 changes: 3 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@
# @param dburl
# Set this if you wish to use a custom database URL
# @param connection_settings
# Configures JDBC connection settings
# Configures additional JDBC connection properties in dbconfig.xml
# For PostgreSQL, a default value of "tcpKeepAlive=true;socketTimeout=240" will be used
# See https://confluence.atlassian.com/jirakb/connection-problems-to-postgresql-result-in-stuck-threads-in-jira-1047534091.html
# @param oracle_use_sid
# Affects the database URL format for Oracle depending on whether you connect via a SID or a service name
# @param mysql_connector_manage
Expand Down
8 changes: 5 additions & 3 deletions spec/classes/jira_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
with_content(%r{<time-between-eviction-runs-millis>300000}).
with_content(%r{<pool-test-while-idle>true}).
with_content(%r{<pool-test-on-borrow>false}).
with_content(%r{<validation-query>select version\(\);})
with_content(%r{<validation-query>select version\(\);}).
with_content(%r{<connection-properties>tcpKeepAlive=true;socketTimeout=240})
end
it { is_expected.not_to contain_file('/home/jira/cluster.properties') }
it { is_expected.not_to contain_file('/opt/jira/atlassian-jira-software-8.13.5-standalone/bin/check-java.sh') }
Expand Down Expand Up @@ -70,7 +71,8 @@
it do
is_expected.to contain_file('/home/jira/dbconfig.xml').
with_content(%r{<validation-query>select 1</validation-query>}).
with_content(%r{<validation-query-timeout>3</validation-query-timeout>})
with_content(%r{<validation-query-timeout>3</validation-query-timeout>}).
without_content(%r{<connection-properties>})
end
end

Expand All @@ -91,7 +93,7 @@
it { is_expected.to contain_file('/opt/jira/atlassian-jira-software-8.13.5-standalone/conf/server.xml') }
it do
is_expected.to contain_file('/home/jira/dbconfig.xml').
with_content(%r{<connection-settings>TEST-SETTING;</connection-settings>}).
with_content(%r{<connection-properties>TEST-SETTING;</connection-properties>}).
with_content(%r{<pool-max-size>200</pool-max-size>}).
with_content(%r{<pool-min-size>10</pool-min-size>}).
with_content(%r{<validation-query>SELECT myfunction\(\);</validation-query>})
Expand Down
2 changes: 1 addition & 1 deletion templates/dbconfig.xml.epp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<time-between-eviction-runs-millis><%= $jira::config::time_between_eviction_runs %></time-between-eviction-runs-millis>
<% } -%>
<% if $jira::config::connection_settings { -%>
<connection-settings><%= $jira::config::connection_settings %></connection-settings>
<connection-properties><%= $jira::config::connection_settings %></connection-properties>
<% } -%>
</jdbc-datasource>
</jira-database-config>

0 comments on commit a08f33a

Please sign in to comment.