Skip to content

NMS-19541: Minion: Investigate if its possible to move away from Confd#8379

Draft
mershad-manesh wants to merge 41 commits intodevelopfrom
mem/NMS-19541-smoke2
Draft

NMS-19541: Minion: Investigate if its possible to move away from Confd#8379
mershad-manesh wants to merge 41 commits intodevelopfrom
mem/NMS-19541-smoke2

Conversation

@mershad-manesh
Copy link
Copy Markdown
Contributor

Opening this PR to gather feedback;

All Contributors

External References

Copy link
Copy Markdown
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 28 out of 29 changed files in this pull request and generated 3 comments.


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

Comment on lines +323 to +325
jms|"")
# Default/package-provided feature boots are expected to cover JMS.
;;
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

When MINION_IPC is set to jms (or unset), the validator does not ensure that previously-generated kafka-*.boot/grpc.boot files are removed. If /opt/minion/etc is persisted across restarts, switching from kafka/grpc back to jms can leave stale boot files behind and still enable non-JMS IPC features. Consider applying the feature-boot templates (or at least cleaning the managed boot files) on every startup based on the current MINION_IPC, or add explicit checks that conflicting boot files are absent for the jms/default case.

Copilot uses AI. Check for mistakes.
Comment on lines +116 to +120
# Clean only files managed by this script; keep baseline boot files from the image/package.
local managed_boot_files=(
"kafka-ipc.boot"
"kafka-rpc.boot"
"kafka-sink.boot"
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

The cleanup list for managed boot files only removes the new template-generated filenames. If users upgrade with a persisted /opt/minion/etc, older boot files created by previous entrypoint logic (e.g. kafka.boot, disable-activemq.boot, etc.) may remain and conflict with the new kafka-*.boot/disable-jms.boot composition. Consider adding the legacy filenames to the cleanup list (or a broader cleanup strategy) so upgrades don't leave contradictory boot configs behind.

Copilot uses AI. Check for mistakes.
Comment thread opennms-container/minion/container-fs/entrypoint.sh Outdated
Copy link
Copy Markdown
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 28 out of 29 changed files in this pull request and generated 4 comments.


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

withEnv("KAFKA_IPC_BOOTSTRAP_SERVERS", OpenNMSContainer.KAFKA_ALIAS + ":9092");
withEnv("KAFKA_RPC_BOOTSTRAP_SERVERS", OpenNMSContainer.KAFKA_ALIAS + ":9092");
withEnv("KAFKA_SINK_BOOTSTRAP_SERVERS", OpenNMSContainer.KAFKA_ALIAS + ":9092");
withEnv("KAFKA_TWIN_BOOTSTRAP_SERVERS", OpenNMSContainer.KAFKA_ALIAS + ":9092");
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

When using Kafka IPC, the Minion container no longer propagates the stack’s Kafka compression strategy (previously written as compression.type in the generated config). This can lead to inconsistent producer settings vs OpenNMS/Sentinel and potentially larger network usage. Consider setting KAFKA_IPC_COMPRESSION_TYPE (and any other required Kafka client properties) from model.getKafkaCompressionStrategy().getCodec() when IpcStrategy.KAFKA is selected.

Suggested change
withEnv("KAFKA_TWIN_BOOTSTRAP_SERVERS", OpenNMSContainer.KAFKA_ALIAS + ":9092");
withEnv("KAFKA_TWIN_BOOTSTRAP_SERVERS", OpenNMSContainer.KAFKA_ALIAS + ":9092");
if (model.getKafkaCompressionStrategy() != null
&& model.getKafkaCompressionStrategy().getCodec() != null) {
withEnv("KAFKA_IPC_COMPRESSION_TYPE", model.getKafkaCompressionStrategy().getCodec());
}

Copilot uses AI. Check for mistakes.
Comment on lines +152 to +155
withEnv("OPENNMS_BROKER_URL", "failover:tcp://" + OpenNMSContainer.ALIAS + ":61616");

if (IpcStrategy.KAFKA.equals(model.getIpcStrategy())) {
String kafkaIpc = "{\n" +
"\t\"ipc\": {\n" +
"\t\t\"kafka\": {\n" +
"\t\t\t\"bootstrap.servers\": \""+ OpenNMSContainer.KAFKA_ALIAS +":9092\",\n" +
"\t\t\t\"compression.type\": \""+ model.getKafkaCompressionStrategy().getCodec() +"\"\n" +
"\t\t}\n" +
"\t}\n" +
"}";
OverlayUtils.writeYaml(minionConfigYaml, jsonMapper.readValue(kafkaIpc, Map.class));
withEnv("MINION_IPC", "kafka");
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

The removal of minion-config.yaml generation leaves several unused imports/static imports in this class (eg jsonMapper, createTempDirectory, File, FileUtils, MountableFile). Please remove the now-unused imports to keep the file clean and avoid failing style/lint checks.

Copilot uses AI. Check for mistakes.
Comment thread opennms-container/minion/container-fs/entrypoint.sh Outdated
Comment on lines +154 to +156
*)
echo "[Features] No IPC strategy set via MINION_IPC, using defaults."
;;
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

parseEnvironment still writes Kafka config when KAFKA_IPC_* variables are set, but applyFeatureBootTemplates only enables the Kafka feature boot files when MINION_IPC=kafka. This allows a partially-configured state (Kafka properties set but Kafka features not enabled) that’s hard to diagnose. Consider auto-selecting MINION_IPC=kafka when KAFKA_IPC_* vars are present, or emitting a clear warning/error when Kafka vars are set without MINION_IPC.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
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 28 out of 29 changed files in this pull request and generated 5 comments.


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

Comment on lines +1 to +2
acks = ${env:KAFKA_RPC_ACKS:-1}
bootstrap.servers = ${env:KAFKA_RPC_BOOTSTRAP_SERVERS:-kafka:29092}
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

The updateConfig helper in entrypoint.sh matches/replaces only key=value (no whitespace). With the current key = value formatting here, env-var updates will append a second entry (e.g. bootstrap.servers=...) instead of replacing the default, leaving duplicate keys in the same .cfg file. Use consistent key=value formatting (or update updateConfig to handle optional whitespace) to avoid ambiguous config resolution.

Suggested change
acks = ${env:KAFKA_RPC_ACKS:-1}
bootstrap.servers = ${env:KAFKA_RPC_BOOTSTRAP_SERVERS:-kafka:29092}
acks=${env:KAFKA_RPC_ACKS:-1}
bootstrap.servers=${env:KAFKA_RPC_BOOTSTRAP_SERVERS:-kafka:29092}

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +2
acks = ${env:KAFKA_SINK_ACKS:-1}
bootstrap.servers = ${env:KAFKA_SINK_BOOTSTRAP_SERVERS:-kafka:29092}
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

The updateConfig helper in entrypoint.sh matches/replaces only key=value (no whitespace). With the current key = value formatting here, env-var updates will append a second entry instead of replacing the default, leaving duplicate keys in the same .cfg file. Use consistent key=value formatting (or update updateConfig to handle optional whitespace) to avoid ambiguous config resolution.

Suggested change
acks = ${env:KAFKA_SINK_ACKS:-1}
bootstrap.servers = ${env:KAFKA_SINK_BOOTSTRAP_SERVERS:-kafka:29092}
acks=${env:KAFKA_SINK_ACKS:-1}
bootstrap.servers=${env:KAFKA_SINK_BOOTSTRAP_SERVERS:-kafka:29092}

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +2
acks = ${env:KAFKA_TWIN_ACKS:-1}
bootstrap.servers = ${env:KAFKA_TWIN_BOOTSTRAP_SERVERS:-kafka:29092}
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

The updateConfig helper in entrypoint.sh matches/replaces only key=value (no whitespace). With the current key = value formatting here, env-var updates will append a second entry instead of replacing the default, leaving duplicate keys in the same .cfg file. Use consistent key=value formatting (or update updateConfig to handle optional whitespace) to avoid ambiguous config resolution.

Suggested change
acks = ${env:KAFKA_TWIN_ACKS:-1}
bootstrap.servers = ${env:KAFKA_TWIN_BOOTSTRAP_SERVERS:-kafka:29092}
acks=${env:KAFKA_TWIN_ACKS:-1}
bootstrap.servers=${env:KAFKA_TWIN_BOOTSTRAP_SERVERS:-kafka:29092}

Copilot uses AI. Check for mistakes.
Comment on lines +152 to +163
withEnv("OPENNMS_BROKER_URL", "failover:tcp://" + OpenNMSContainer.ALIAS + ":61616");

if (IpcStrategy.KAFKA.equals(model.getIpcStrategy())) {
String kafkaIpc = "{\n" +
"\t\"ipc\": {\n" +
"\t\t\"kafka\": {\n" +
"\t\t\t\"bootstrap.servers\": \""+ OpenNMSContainer.KAFKA_ALIAS +":9092\",\n" +
"\t\t\t\"compression.type\": \""+ model.getKafkaCompressionStrategy().getCodec() +"\"\n" +
"\t\t}\n" +
"\t}\n" +
"}";
OverlayUtils.writeYaml(minionConfigYaml, jsonMapper.readValue(kafkaIpc, Map.class));
withEnv("MINION_IPC", "kafka");
withEnv("KAFKA_IPC_BOOTSTRAP_SERVERS", OpenNMSContainer.KAFKA_ALIAS + ":9092");
withEnv("KAFKA_RPC_BOOTSTRAP_SERVERS", OpenNMSContainer.KAFKA_ALIAS + ":9092");
withEnv("KAFKA_SINK_BOOTSTRAP_SERVERS", OpenNMSContainer.KAFKA_ALIAS + ":9092");
withEnv("KAFKA_TWIN_BOOTSTRAP_SERVERS", OpenNMSContainer.KAFKA_ALIAS + ":9092");
if (model.getKafkaCompressionStrategy() != null) {
withEnv("KAFKA_IPC_COMPRESSION_TYPE", model.getKafkaCompressionStrategy().getCodec());
withEnv("KAFKA_SINK_COMPRESSION_TYPE", model.getKafkaCompressionStrategy().getCodec());
withEnv("KAFKA_TWIN_COMPRESSION_TYPE", model.getKafkaCompressionStrategy().getCodec());
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

After removing the on-the-fly minion-config.yaml generation, this class appears to retain several now-unused imports/static imports (e.g. createTempDirectory, jsonMapper, FileUtils, MountableFile, etc.). If the build uses Checkstyle/Spotless or error-prone rules, these unused imports can fail CI; please remove any that are no longer referenced.

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +2
syslog.listen.interface = ${env:SYSLOG_LISTEN_INTERFACE:-0.0.0.0}
syslog.listen.port = ${env:SYSLOG_LISTEN_PORT:-1514}
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

Environment variable naming is inconsistent between syslog and trapd configs in this PR (SYSLOG_LISTEN_* here vs MINION_TRAPD_LISTEN_* in trapd). Aligning the prefixes (or documenting why they differ) would reduce confusion for container users configuring multiple listeners.

Suggested change
syslog.listen.interface = ${env:SYSLOG_LISTEN_INTERFACE:-0.0.0.0}
syslog.listen.port = ${env:SYSLOG_LISTEN_PORT:-1514}
syslog.listen.interface = ${env:MINION_SYSLOG_LISTEN_INTERFACE:-0.0.0.0}
syslog.listen.port = ${env:MINION_SYSLOG_LISTEN_PORT:-1514}

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
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 85 out of 86 changed files in this pull request and generated 3 comments.


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

Comment on lines 33 to 38
# - All other settings are optional and have sensible defaults
#
# Default behavior:
# - Configuration is managed via confd templates
# - Configuration is managed via environment variables, which can be set in the Dockerfile, via docker run -e, or in a docker-compose file.
# - Template uses key/values from /java/agent/prom-jmx-exporter
PROM_JMX_EXPORTER_ENABLED="${PROM_JMX_EXPORTER_ENABLED:-false}" # required
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

The comment still says the Prometheus JMX exporter "Template uses key/values from /java/agent/prom-jmx-exporter", but this PR removes confd/template rendering for that file. Update the comment to reflect the current behavior (env-var driven config + static config file) to avoid misleading operators.

Copilot uses AI. Check for mistakes.
Comment on lines 108 to 113
# If config exists in file, replace it. Otherwise, append to file.
if grep -E -q "^#?$key=" "$file"; then
sed -r -i "s@^#?$key=.*@$key=$value@g" "$file" #note that no config values may contain an '@' char
if grep -E -q "^#?\s*$key\s*=" "$file"; then
sed -r -i "s@^#?\s*$key\s*=.*@$key=$value@g" "$file" #note that no config values may contain an '@' char
else
echo "$key=$value" >> "$file"
fi
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

updateConfig treats key as an extended-regex in both grep -E and sed, but keys like bootstrap.servers contain . which will match any character. Also, the replacement uses the raw value, so characters like &, \, or the chosen delimiter (@) can corrupt the result. Consider switching to fixed-string matching (or escaping regex metacharacters in key) and escaping value for safe sed replacement (or using a non-regex-based updater) to make env-driven config robust.

Copilot uses AI. Check for mistakes.
Comment on lines 141 to 146
if (profile.isLegacy()) {
for (final Map.Entry<String, String> entry : profile.getLegacyConfiguration().entrySet()) {
addEnv(entry.getKey(), entry.getValue());
}
} else {
addFileSystemBind(writeMinionConfig(profile).toString(),
"/opt/minion/minion-config.yaml", BindMode.READ_ONLY, SelinuxContext.SINGLE);
}

Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

After removing the minion-config YAML generation/bind logic, several imports at the top of this file are now unused (e.g. createTempDirectory, jsonMapper, File, FileUtils, MountableFile). This will fail the build under typical Java compiler settings/checkstyle—please remove the unused imports.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

@cgorantla cgorantla left a comment

Choose a reason for hiding this comment

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

  1. I think we should move templates folder which has boot files to something outside etc to avoid confusion with featuresBoot.d. For ex: ${MINION_HOME}/boot-templates/
    We can keep current MINION_IPC=kafka logic where we disable JMS and enable Kafka.

  2. I think we can avoid shipping with .cfg files. Let user customize. We can create all these .cfg files in smoke-test overlay for smoke tests to pass.

  3. When user creates their own docker compose or helm charts, they can create their own version of cfg files with custom environment variables. We may not need to enforce this.

@mershad-manesh
Copy link
Copy Markdown
Contributor Author

  1. I think we should move templates folder which has boot files to something outside etc to avoid confusion with featuresBoot.d. For ex: ${MINION_HOME}/boot-templates/
    We can keep current MINION_IPC=kafka logic where we disable JMS and enable Kafka.

We can move it to another folder, this shouldn't be a problem.

  1. I think we can avoid shipping with .cfg files. Let user customize. We can create all these .cfg files in smoke-test overlay for smoke tests to pass.

Although this will work for smoke tests, it wouldn't be straight forward for users who are using Docker or Helm Charts. How would they know what they need to provide for each configuration file...

  1. When user creates their own docker compose or helm charts, they can create their own version of cfg files with custom environment variables. We may not need to enforce this.

It's fine if user overrides these cfg files, however we still need a basic set of cfg files to allow Minion to start.

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.

3 participants