Skip to content

issue/64 add env vars to omns-core-init.sh to configure opennms-datas…#80

Open
makikorp wants to merge 4 commits intomainfrom
issue/64
Open

issue/64 add env vars to omns-core-init.sh to configure opennms-datas…#80
makikorp wants to merge 4 commits intomainfrom
issue/64

Conversation

@makikorp
Copy link
Contributor

…ources.xml

@makikorp makikorp requested a review from Copilot November 12, 2025 20:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds environment variable configuration support for OpenNMS database connection pool settings in the initialization script. Previously, most connection pool parameters were hardcoded; now they can be configured via environment variables.

Key Changes:

  • Added environment variables for database connection pool configuration (idle timeout, login timeout, min pool, max pool, max size)
  • Applied these configurable parameters to all three database connection configurations in opennms-datasources.xml
  • Bumped chart version from 1.1.20 to 1.1.21

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
horizon/scripts/onms-core-init.sh Added environment variable defaults and applied them to database connection pool configurations in opennms-datasources.xml
horizon/Chart.yaml Incremented chart version to reflect the configuration changes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

# Defaults
OPENNMS_DATABASE_CONNECTION_IDLETIMEOUT="${OPENNMS_DATABASE_CONNECTION_IDLETIMEOUT:-600}"
OPENNMS_DATABASE_CONNECTION_LOGINTIMEOUT="${OPENNMS_DATABASE_CONNECTION_LOGINTIMEOUT:-3}"
OPENNMS_DATABASE_CONNECTION_MINPOOL="${OPENNMS_DATABASE_CONNECTION_MAXSIZE:-25}"
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MINPOOL variable is incorrectly using MAXSIZE as its source. It should use OPENNMS_DATABASE_CONNECTION_MINPOOL instead: OPENNMS_DATABASE_CONNECTION_MINPOOL=\"${OPENNMS_DATABASE_CONNECTION_MINPOOL:-25}\"

Suggested change
OPENNMS_DATABASE_CONNECTION_MINPOOL="${OPENNMS_DATABASE_CONNECTION_MAXSIZE:-25}"
OPENNMS_DATABASE_CONNECTION_MINPOOL="${OPENNMS_DATABASE_CONNECTION_MINPOOL:-25}"

Copilot uses AI. Check for mistakes.
@makikorp makikorp self-assigned this Nov 12, 2025
@makikorp makikorp requested a review from Copilot November 12, 2025 20:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

maxPool="10"
maxSize="50" />
<connection-pool idleTimeout="${OPENNMS_DATABASE_CONNECTION_IDLETIMEOUT}"
minPool="${OPENNMS_DATABASE_CONNECTION_MINPOOL}"
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The minPool values for template1 and postgres datasources are now set to 25 (from the default), but were previously hardcoded to 0. This changes the behavior of these connection pools and may cause resource consumption issues. Consider using a separate environment variable for these datasources or documenting this breaking change.

Copilot uses AI. Check for mistakes.
maxPool="10"
maxSize="50" />
<connection-pool idleTimeout="${OPENNMS_DATABASE_CONNECTION_IDLETIMEOUT}"
minPool="${OPENNMS_DATABASE_CONNECTION_MINPOOL}"
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The minPool values for template1 and postgres datasources are now set to 25 (from the default), but were previously hardcoded to 0. This changes the behavior of these connection pools and may cause resource consumption issues. Consider using a separate environment variable for these datasources or documenting this breaking change.

Copilot uses AI. Check for mistakes.
@makikorp makikorp assigned indigo423 and unassigned makikorp Nov 12, 2025
@makikorp makikorp requested a review from indigo423 November 12, 2025 21:52
@makikorp makikorp assigned makikorp and indigo423 and unassigned indigo423 Nov 12, 2025
@makikorp makikorp removed their assignment Nov 25, 2025
@makikorp makikorp requested a review from Copilot January 8, 2026 22:51
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 288 to 290

EOF
if $USE_UPDATED_DATASOURCE; then
cat <<EOF >> ${CONFIG_DIR_OVERLAY}/opennms-datasources.xml
<jdbc-data-source name="opennms-admin"
database-name="template1"
class-name="org.postgresql.Driver"
url="jdbc:postgresql://${POSTGRES_HOST}:${POSTGRES_PORT}/template1?sslmode=${POSTGRES_SSL_MODE}&amp;sslfactory=${POSTGRES_SSL_FACTORY}"
user-name="${POSTGRES_USER}"
password="${POSTGRES_PASSWORD}">
<connection-pool idleTimeout="600"
minPool="0"
maxPool="10"
maxSize="50" />
</jdbc-data-source>

<jdbc-data-source name="opennms-monitor"
database-name="postgres"
class-name="org.postgresql.Driver"
url="jdbc:postgresql://${POSTGRES_HOST}:${POSTGRES_PORT}/postgres?sslmode=${POSTGRES_SSL_MODE}&amp;sslfactory=${POSTGRES_SSL_FACTORY}"
user-name="${POSTGRES_USER}"
password="${POSTGRES_PASSWORD}">
<connection-pool idleTimeout="600"
minPool="0"
maxPool="10"
maxSize="50" />
</jdbc-data-source>
</datasource-configuration>
EOF
else
cat <<EOF >> ${CONFIG_DIR_OVERLAY}/opennms-datasources.xml
<jdbc-data-source name="opennms-admin"
database-name="template1"
class-name="org.postgresql.Driver"
url="jdbc:postgresql://${POSTGRES_HOST}:${POSTGRES_PORT}/template1?sslmode=${POSTGRES_SSL_MODE}&amp;sslfactory=${POSTGRES_SSL_FACTORY}"
user-name="${POSTGRES_USER}"
password="${POSTGRES_PASSWORD}"/>
</datasource-configuration>
EOF
fi

# Enable storeByGroup to improve performance
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of the datasource configuration logic leaves no clear indication of how opennms-datasources.xml should now be configured. Consider adding a comment explaining the new approach for configuring database connections, or verify that this configuration is now handled elsewhere (e.g., via environment variables, a ConfigMap, or a different initialization mechanism).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants