Skip to content

NMS-19753: Core: Investigate if its possible to move away from Confd#8497

Open
mershad-manesh wants to merge 20 commits into
features/NMS-19406from
mem/NMS-19753-1.x
Open

NMS-19753: Core: Investigate if its possible to move away from Confd#8497
mershad-manesh wants to merge 20 commits into
features/NMS-19406from
mem/NMS-19753-1.x

Conversation

@mershad-manesh

Copy link
Copy Markdown
Contributor

All Contributors

External References

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 removes the confd-based runtime templating approach from the OpenNMS core container image and replaces it with environment-variable-driven configuration (static files + envsubst), updating documentation and smoke tests accordingly.

Changes:

  • Replace confd template processing with environment-variable config processing in the container entrypoint.
  • Add static container config files/templates and default Prometheus JMX exporter config to the image; remove confd templates/TOML definitions.
  • Update smoke tests to always set OPENNMS_TIMESERIES_STRATEGY based on the stack model.

Reviewed changes

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

Show a summary per file
File Description
smoke-test/src/main/java/org/opennms/smoketest/containers/OpenNMSContainer.java Always exports OPENNMS_TIMESERIES_STRATEGY to align with env-var-driven container config.
opennms-container/core/container-fs/prom-jmx-default-config.yaml Replace confd-rendered JMX exporter config with a static default YAML.
opennms-container/core/container-fs/etc/templates/trapd-configuration.xml.tmpl New envsubst template for trapd-configuration.xml.
opennms-container/core/container-fs/etc/templates/service-configuration.xml.tmpl New envsubst template for service-configuration.xml service enablement toggles.
opennms-container/core/container-fs/etc/org.apache.karaf.shell.cfg New static Karaf SSH config using ${env:...} substitution.
opennms-container/core/container-fs/etc/opennms.properties.d/_container.timeseries.properties New properties file for timeseries/rrd config via `${env:...
opennms-container/core/container-fs/etc/opennms.properties.d/_container.slack.properties New Slack notification properties via environment variables.
opennms-container/core/container-fs/etc/opennms.properties.d/_container.newts.properties New Newts/Cassandra properties via environment variables.
opennms-container/core/container-fs/etc/opennms.properties.d/_container.mattermost.properties New Mattermost notification properties via environment variables.
opennms-container/core/container-fs/entrypoint.sh Introduce processEnvConfig() and switch startup flow away from confd -onetime.
opennms-container/core/container-fs/confd/templates/trapd-configuration.xml.tmpl Remove confd template (replaced by envsubst template).
opennms-container/core/container-fs/confd/templates/timeseries.properties.tmpl Remove confd template (replaced by _container.timeseries.properties).
opennms-container/core/container-fs/confd/templates/slack.properties.tmpl Remove confd template (replaced by _container.slack.properties).
opennms-container/core/container-fs/confd/templates/service-configuration.xml.tmpl Remove confd template (replaced by envsubst template).
opennms-container/core/container-fs/confd/templates/org.apache.karaf.shell.cfg.tmpl Remove confd template (replaced by static cfg file).
opennms-container/core/container-fs/confd/templates/newts.properties.tmpl Remove confd template (replaced by _container.newts.properties).
opennms-container/core/container-fs/confd/templates/mattermost.properties.tmpl Remove confd template (replaced by _container.mattermost.properties).
opennms-container/core/container-fs/confd/confd.toml Remove confd configuration.
opennms-container/core/container-fs/confd/conf.d/trapd-configuration.xml.toml Remove confd template mapping.
opennms-container/core/container-fs/confd/conf.d/timeseries.properties.toml Remove confd template mapping.
opennms-container/core/container-fs/confd/conf.d/slack.properties.toml Remove confd template mapping.
opennms-container/core/container-fs/confd/conf.d/service-configuration.xml.toml Remove confd template mapping.
opennms-container/core/container-fs/confd/conf.d/prom-jmx-exporter.yaml.toml Remove confd template mapping (replaced by static default config).
opennms-container/core/container-fs/confd/conf.d/org.apache.karaf.shell.cfg.toml Remove confd template mapping.
opennms-container/core/container-fs/confd/conf.d/newts.properties.toml Remove confd template mapping.
opennms-container/core/container-fs/confd/conf.d/mattermost.properties.toml Remove confd template mapping.
opennms-container/core/Dockerfile Add gettext (for envsubst) and copy new container config files + prom-jmx default config into the image.
opennms-container/core/CONFD_README.md Update documentation from confd/yaml-driven config to environment-variable-driven config.

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

Comment thread opennms-container/core/container-fs/etc/org.apache.karaf.shell.cfg Outdated
Comment thread opennms-container/core/ENVIRONMENT_VARIABLES.md
Comment thread opennms-container/core/container-fs/entrypoint.sh Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 migrates the opennms-container/core image startup configuration away from confd-generated templates toward environment-variable-driven configuration (plus optional overlay mounts), as part of NMS-19753.

Changes:

  • Replace confd template processing with envsubst + static config files copied into the runtime /opt/opennms/etc.
  • Add container-managed templates/config for service enablement, Trapd, Karaf SSH config, and multiple opennms.properties.d fragments.
  • Install a static default Prometheus JMX exporter config and add gettext (for envsubst) to the container image.

Reviewed changes

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

Show a summary per file
File Description
smoke-test/src/main/java/org/opennms/smoketest/containers/OpenNMSContainer.java Always sets OPENNMS_TIMESERIES_STRATEGY env var for the smoke-test container.
opennms-container/core/container-fs/prom-jmx-default-config.yaml Replaces confd-templated Prom JMX YAML with a static default config.
opennms-container/core/container-fs/etc/templates/trapd-configuration.xml.tmpl Adds envsubst-driven Trapd XML template.
opennms-container/core/container-fs/etc/templates/service-configuration.xml.tmpl Adds envsubst-driven service enablement template (per-service env vars).
opennms-container/core/container-fs/etc/org.apache.karaf.shell.cfg Adds Karaf SSH config with env-based port/host defaults.
opennms-container/core/container-fs/etc/opennms.properties.d/_container.timeseries.properties Adds env-driven timeseries/RRD property fragment.
opennms-container/core/container-fs/etc/opennms.properties.d/_container.slack.properties Adds env-driven Slack notification properties fragment.
opennms-container/core/container-fs/etc/opennms.properties.d/_container.newts.properties Adds env-driven Newts/Cassandra properties fragment.
opennms-container/core/container-fs/etc/opennms.properties.d/_container.mattermost.properties Adds env-driven Mattermost notification properties fragment.
opennms-container/core/container-fs/entrypoint.sh Replaces confd run with env-based config generation/copying and legacy cleanup.
opennms-container/core/Dockerfile Installs gettext and ships new container-fs config + default prom-jmx config.
opennms-container/core/CONFD_README.md Updates documentation to describe the env-var based configuration and migration notes.
opennms-container/core/container-fs/confd/templates/trapd-configuration.xml.tmpl Removes confd Trapd template (no longer used).
opennms-container/core/container-fs/confd/templates/timeseries.properties.tmpl Removes confd timeseries template (no longer used).
opennms-container/core/container-fs/confd/templates/slack.properties.tmpl Removes confd Slack template (no longer used).
opennms-container/core/container-fs/confd/templates/service-configuration.xml.tmpl Removes confd service configuration template (no longer used).
opennms-container/core/container-fs/confd/templates/org.apache.karaf.shell.cfg.tmpl Removes confd Karaf SSH template (no longer used).
opennms-container/core/container-fs/confd/templates/newts.properties.tmpl Removes confd Newts template (no longer used).
opennms-container/core/container-fs/confd/templates/mattermost.properties.tmpl Removes confd Mattermost template (no longer used).
opennms-container/core/container-fs/confd/confd.toml Removes confd runtime config.
opennms-container/core/container-fs/confd/conf.d/trapd-configuration.xml.toml Removes confd template mapping.
opennms-container/core/container-fs/confd/conf.d/timeseries.properties.toml Removes confd template mapping.
opennms-container/core/container-fs/confd/conf.d/slack.properties.toml Removes confd template mapping.
opennms-container/core/container-fs/confd/conf.d/service-configuration.xml.toml Removes confd template mapping.
opennms-container/core/container-fs/confd/conf.d/prom-jmx-exporter.yaml.toml Removes confd template mapping.
opennms-container/core/container-fs/confd/conf.d/org.apache.karaf.shell.cfg.toml Removes confd template mapping.
opennms-container/core/container-fs/confd/conf.d/newts.properties.toml Removes confd template mapping.
opennms-container/core/container-fs/confd/conf.d/mattermost.properties.toml Removes confd template mapping.

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

Comment thread opennms-container/core/container-fs/entrypoint.sh Outdated
if (TimeSeriesStrategy.NEWTS.equals(model.getTimeSeriesStrategy())) {
this.withEnv("OPENNMS_TIMESERIES_STRATEGY", model.getTimeSeriesStrategy().name().toLowerCase());
}
this.withEnv("OPENNMS_TIMESERIES_STRATEGY", model.getTimeSeriesStrategy().name().toLowerCase());
Comment thread opennms-container/core/container-fs/etc/org.apache.karaf.shell.cfg Outdated
@@ -0,0 +1,6 @@
sshPort=${env:KARAF_SSH_PORT:-8101}
# OPENNMS: Restrict SSH on all interfaces by default;
Comment thread opennms-container/core/container-fs/entrypoint.sh Outdated

If you are upgrading from a version that used `horizon-config.yaml` / confd:

- The `horizon-config.yaml` mount is no longer used. Switch to environment variables using the tables above.
@marshallmassengill

Copy link
Copy Markdown
Contributor

I looked through everything I could and there wasn't anything that felt truly off to me. I also used CC and did a review on this. These were the only two things that I think were worth mentioning here that got flagged and both seem mostly minor:

  • prom-jmx-default-config.yaml lost env-var-driven knobs. The old confd template let operators tune startDelaySeconds, lowercaseOutputName, lowercaseOutputLabelNames, autoExcludeObjectNameAttributes, includeObjectNames, and excludeObjectNames via the /java/agent/prom-jmx-exporter/* keys (which mapped to env vars under confd's env backend). The new file is fully static; the only escape hatch is "mount your own YAML and point PROM_JMX_EXPORTER_CONFIG at it." For users who were tweaking just includeObjectNames, that's a meaningful UX downgrade — they now have to maintain the entire YAML. Either keep an envsubst path for this file too, or call out the regression explicitly in the migration section.
  • No XML-escaping on envsubst substitutions. service-configuration.xml.tmpl and trapd-configuration.xml.tmpl are XML files where ${OPENNMS_TRAPD_ADDRESS} / ${CORE_SERVICE_*_ENABLED} get raw-interpolated. If an operator passes a value containing <, >, &, or ", the resulting XML breaks. The expected values are true/false and an IP address, so this is operator-controlled and unlikely to be exploited, but a minute of input validation in processEnvConfig (e.g. assert booleans match ^(true|false)$) would prevent a confusing parse failure later in configTester

@github-actions github-actions Bot added the docs label May 26, 2026
Comment thread opennms-container/core/container-fs/etc/templates/service-configuration.xml.tmpl Outdated
Comment thread opennms-container/core/container-fs/entrypoint.sh Outdated
Comment thread opennms-container/core/container-fs/entrypoint.sh Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 30 out of 30 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

opennms-container/core/container-fs/etc/templates/prom-jmx-exporter-config.yaml.tmpl:4

  • envsubst does not evaluate shell default expressions such as ${VAR:-default}; it only substitutes simple $VAR/${VAR} references. Since processEnvConfig() already exports defaults before calling envsubst, these lines should use simple variable references, otherwise the generated YAML will retain the literal ${...:-...} strings.

Comment thread opennms-container/core/container-fs/entrypoint.sh
Comment thread opennms-container/core/ENVIRONMENT_VARIABLES.md Outdated
Comment thread opennms-container/core/container-fs/entrypoint.sh Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants