NMS-19541: Minion: Investigate if its possible to move away from Confd#8379
NMS-19541: Minion: Investigate if its possible to move away from Confd#8379mershad-manesh wants to merge 41 commits intodevelopfrom
Conversation
This reverts commit 91cf192.
There was a problem hiding this comment.
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.
| jms|"") | ||
| # Default/package-provided feature boots are expected to cover JMS. | ||
| ;; |
There was a problem hiding this comment.
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.
| # 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" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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.
| 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()); | |
| } |
| 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"); |
There was a problem hiding this comment.
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.
| *) | ||
| echo "[Features] No IPC strategy set via MINION_IPC, using defaults." | ||
| ;; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
| acks = ${env:KAFKA_RPC_ACKS:-1} | ||
| bootstrap.servers = ${env:KAFKA_RPC_BOOTSTRAP_SERVERS:-kafka:29092} |
There was a problem hiding this comment.
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.
| 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} |
| acks = ${env:KAFKA_SINK_ACKS:-1} | ||
| bootstrap.servers = ${env:KAFKA_SINK_BOOTSTRAP_SERVERS:-kafka:29092} |
There was a problem hiding this comment.
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.
| 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} |
| acks = ${env:KAFKA_TWIN_ACKS:-1} | ||
| bootstrap.servers = ${env:KAFKA_TWIN_BOOTSTRAP_SERVERS:-kafka:29092} |
There was a problem hiding this comment.
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.
| 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} |
| 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()); |
There was a problem hiding this comment.
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.
| syslog.listen.interface = ${env:SYSLOG_LISTEN_INTERFACE:-0.0.0.0} | ||
| syslog.listen.port = ${env:SYSLOG_LISTEN_PORT:-1514} |
There was a problem hiding this comment.
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.
| 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} |
There was a problem hiding this comment.
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.
| # - 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 |
There was a problem hiding this comment.
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.
| # 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 |
There was a problem hiding this comment.
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.
| 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); | ||
| } | ||
|
|
There was a problem hiding this comment.
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.
This reverts commit aea6221.
cgorantla
left a comment
There was a problem hiding this comment.
-
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 currentMINION_IPC=kafkalogic where we disable JMS and enable Kafka. -
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.
-
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.
We can move it to another folder, this shouldn't be a problem.
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...
It's fine if user overrides these cfg files, however we still need a basic set of cfg files to allow Minion to start. |
Opening this PR to gather feedback;
All Contributors
External References