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

helm install fails with annotations with complex values #698

Closed
kencharos opened this issue Jul 26, 2024 · 1 comment
Closed

helm install fails with annotations with complex values #698

kencharos opened this issue Jul 26, 2024 · 1 comment

Comments

@kencharos
Copy link

kencharos commented Jul 26, 2024

vesrion: 0.7.1

I tried annotation configuration from https://github.com/open-feature/open-feature-operator/releases/tag/v0.7.1 .

I am considering monitoring fladg pod by datadog and tried to set up a monitoring configuration annotation for open metrics.

pease see about datadog openmetrics configuration in here

This is values.yaml that I tried.

annotations:
  ad.datadoghq.com/flagd.checks: |
    {
      "openmetrics": {
        "instances": [
          {
            "openmetrics_endpoint": "http://%%host%%:8014/metrics",
            "namespace": "flagd",
            "metrics": ["feature_flag.*"]
          }
        ]
      }
    }

Then, Helm install is failed by Invalid Yaml

Error: YAML parse error on open-feature-operator/templates/apps_v1_deployment_open-feature-operator-controller-manager.yaml: error converting YAML to JSON: yaml: line 54: did not find expected key.

The following are the debugging results of the helm template.
It appears that the --annotation option setting requires escaping of the annotation value.

# Source: open-feature-operator/templates/apps_v1_deployment_open-feature-operator-controller-manager.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    control-plane: controller-manager
  name: open-feature-operator-controller-manager
  namespace: 'open-feature-operator-system'
spec:
  replicas: 01
  selector:
    matchLabels:
      control-plane: controller-manager
  template:
    metadata:
      annotations:
        ad.datadoghq.com/flagd.checks: |
          {
            "openmetrics": {
              "instances": [
                {
                  "openmetrics_endpoint": "http://%%host%%:8014/metrics",
                  "namespace": "flagd",
                  "metrics": ["feature_flag.*"]
                }
              ]
            }
          }
        kubectl.kubernetes.io/default-container: manager
      labels:

        control-plane: controller-manager
    spec:
      imagePullSecrets:  
                []
      containers:
      - args:
        - --leader-elect
        - --sidecar-cpu-limit=500m
        - --sidecar-ram-limit=64Mi
        - --sidecar-cpu-request=200m
        - --sidecar-ram-request=32Mi
        - --image-pull-secrets=
        - --metrics-bind-address=:8080
        - --labels=
        - --annotations=ad.datadoghq.com/flagd.checks:{
  "openmetrics": {
    "instances": [
      {
        "openmetrics_endpoint": "http://%%host%%:8014/metrics",
        "namespace": "flagd",
        "metrics": ["feature_flag.*"]
      }
    ]
  }
}

Also, looking StringToMap , it appears that we cannot have commas or colons as annotation values.

Not only datadog, but also annotations often have complex values such as JSON and YAML, so it would be great if you could consider supporting this.

@toddbaert
Copy link
Member

toddbaert commented Oct 2, 2024

Due to some complexities in templating, I don't think we'll be supporting this.

You might be able to get away with using the YAML folded string operator (>) instead of the pipe (|) which will remove newlines, but I don't know for sure that will work.

The thing that will certainly work is to remove the newlines entirely, either by keeping the JSON a string literal following | or > or by escaping it entirely.

Thanks @kencharos . 🙏 I hope you can work around this.

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

No branches or pull requests

2 participants