Skip to content

fix: Accept jmx config as object or array - #404

Merged
jefchien merged 2 commits into
mainfrom
fix/jmx-array-config
Aug 4, 2026
Merged

fix: Accept jmx config as object or array#404
jefchien merged 2 commits into
mainfrom
fix/jmx-array-config

Conversation

@lorespiz

Copy link
Copy Markdown
Contributor

Description of changes: Added a custom UnmarshalJSON on the jmx marker struct in internal/manifests/collector/adapters/config_from.go that accepts both a single object or an array and returns an error for any other type.
The field remains a *jmx pointer, so all existing presence checks (e.g. in ports.go and controllers/common.go) work unchanged; no call sites needed modification.

Testing:

  • Added unit testing TestConfigStructFromJSONString.
  • Manual E2E test on EKS cluster:
    • Built the operator image from this branch and deployed it via make deploy
    • Applied an AmazonCloudWatchAgent CR (daemonset mode) with jmx configured as a two-element array
    • Verified: cloudwatch-agent and cloudwatch-agent-headless Services are created with port 4314/TCP, persist across reconciles, and no config-parsing errors appear in the operator logs

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Comment thread internal/manifests/collector/test-resources/jmxAgentArrayConfig.json Outdated
@jefchien
jefchien merged commit ae22c47 into main Aug 4, 2026
12 of 14 checks passed
@jefchien
jefchien deleted the fix/jmx-array-config branch August 4, 2026 18:36
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.

4 participants