Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forcing YAML conversion for otelConfig field #117

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mitali-salvi
Copy link
Contributor

@mitali-salvi mitali-salvi commented Oct 23, 2024

Description of changes:

  1. Add a YAML parser while reading string YAML for otelConfig field for amazoncloudwatchagent.
  2. The toYAML function converts the string to a YAML as long as the string is correctly indented. Malformed strings will cause an error

Testing

helm upgrade --install  --debug --namespace amazon-cloudwatch amazon-cloudwatch-operator ./ --create-namespace --set region={regionName} --set clusterName={clusterName} --set agent.otelConfig='
extensions:
  health_check:
receivers:
  otlp:
exporters:
  awsemf:
service:
  pipelines:
    metrics/test:
      receivers: [otlp]
      exporters: [awsemf]
  extensions: [health_check]'

Cloudwatch Agent config-map


Data
====
cwagentotelconfig.yaml:
----
exporters:
  awsemf: null
extensions:
  health_check: null
receivers:
  otlp: null
service:
  extensions:
  - health_check
  pipelines:
    metrics/test:
      exporters:
      - awsemf
      receivers:
      - otlp

Negative testing

helm upgrade --install  --debug --namespace amazon-cloudwatch amazon-cloudwatch-operator ./ --create-namespace --set region=us-west-2 --set clusterName=my-dev-cluster --set agent.otelConfig='
extensions:
          health_check:
        receivers:
  otlp:
        exporters:
  awsemf:
service:
  pipelines:
    metrics/test:
      receivers: [otlp]
      exporters: [awsemf]
  extensions: [health_check]'
.
.
.
.
.

helm.go:84: [debug] template: amazon-cloudwatch-observability/templates/linux/cloudwatch-agent-daemonset.yaml:49:17: executing "amazon-cloudwatch-observability/templates/linux/cloudwatch-agent-daemonset.yaml" at <include "cloudwatch-agent.modify-yaml-config" (merge (dict "OtelConfig" .Values.agent.otelConfig) .)>: error calling include: template: amazon-cloudwatch-observability/templates/_helpers.tpl:55:28: executing "cloudwatch-agent.modify-yaml-config" at <$component>: range can't iterate over error converting YAML to JSON: yaml: line 3: found character that cannot start any token

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

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