fluxcd / helm-controller

The GitOps Toolkit Helm reconciler, for declarative Helming
https://fluxcd.io
Apache License 2.0
408 stars 163 forks source link

HelmRelease valuesFrom broken for dotted annotations #542

Closed as42sl closed 2 years ago

as42sl commented 2 years ago

Describe the bug

I just upgraded to the latest release and found out that it is not possible anymore to set dotted annotations with valuesFrom.

Example:

apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
....
  valuesFrom:
    - kind: Secret
      name: my-secret
      valuesKey: my-value
      targetPath: ingress.annotations.alb\.ingress\.kubernetes\.io/some-key

This used to work perfectly. With the latest version it says:

spec.valuesFrom.targetPath: Invalid value: "ingress.annotations.alb\\.ingress\\.kubernetes\\.io/some-key": spec.valuesFrom.targetPath in body should match '^([a-zA-Z0-9_\-.\/]|\[[0-9]{1,5}\])+$'

Steps to reproduce

Try valuesFrom with a annotation containing dots.

`apiVersion: helm.toolkit.fluxcd.io/v2beta1 kind: HelmRelease .... valuesFrom:

Expected behavior

it should set the value for the annotation

Screenshots and recordings

No response

OS / Distro

N/A

Flux version

flux: v0.35.0

Flux check

✔ Kubernetes 1.23.10-eks-15b7512 >=1.20.6-0 ► checking controllers ✔ helm-controller: deployment ready ► ghcr.io/fluxcd/helm-controller:v0.25.0 ✔ image-automation-controller: deployment ready ► ghcr.io/fluxcd/image-automation-controller:v0.26.0 ✔ image-reflector-controller: deployment ready ► ghcr.io/fluxcd/image-reflector-controller:v0.22.0 ✔ kustomize-controller: deployment ready ► ghcr.io/fluxcd/kustomize-controller:v0.29.0 ✔ notification-controller: deployment ready ► ghcr.io/fluxcd/notification-controller:v0.27.0 ✔ source-controller: deployment ready ► ghcr.io/fluxcd/source-controller:v0.30.0 ► checking crds ✔ alerts.notification.toolkit.fluxcd.io/v1beta1 ✔ buckets.source.toolkit.fluxcd.io/v1beta2 ✔ gitrepositories.source.toolkit.fluxcd.io/v1beta2 ✔ helmcharts.source.toolkit.fluxcd.io/v1beta2 ✔ helmreleases.helm.toolkit.fluxcd.io/v2beta1 ✔ helmrepositories.source.toolkit.fluxcd.io/v1beta2 ✔ imagepolicies.image.toolkit.fluxcd.io/v1beta1 ✔ imagerepositories.image.toolkit.fluxcd.io/v1beta1 ✔ imageupdateautomations.image.toolkit.fluxcd.io/v1beta1 ✔ kustomizations.kustomize.toolkit.fluxcd.io/v1beta2 ✔ ocirepositories.source.toolkit.fluxcd.io/v1beta2 ✔ providers.notification.toolkit.fluxcd.io/v1beta1 ✔ receivers.notification.toolkit.fluxcd.io/v1beta1 ✔ all checks passed

Git provider

No response

Container Registry provider

No response

Additional context

No response

Code of Conduct

hiddeco commented 2 years ago

This seems to be related to #520, although the regex introduced there allows both . and \.

My gut feeling tells me it has something to do with the captured group (https://regex101.com/r/alhLe9/1) which makes the validator trip.

hiddeco commented 2 years ago

Given the issue was just closed I guess this was a user input error, as the example works fine for me:

apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
  name: podinfo-helmrepository
spec:
  interval: 5m
  valuesFrom:
    - kind: Secret
      name: my-secret
      valuesKey: my-value
      targetPath: ingress.annotations.alb\.ingress\.kubernetes\.io/some-key
...
$ kubectl apply -f test.yaml
helmrelease.helm.toolkit.fluxcd.io/podinfo-helmrepository created
as42sl commented 2 years ago

Hi, the problem still occurs. I only closed this one because i thought it is the flux1 repo.

hiddeco commented 2 years ago

Can you please post an exact copy of your .spec.valuesFrom?

as42sl commented 2 years ago

Could the issue be in the community helm chart? https://github.com/fluxcd-community/helm-charts/blame/main/charts/flux2/templates/helm-controller.crds.yaml#L723 vs https://github.com/fluxcd/helm-controller/blame/main/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml#L708

as42sl commented 2 years ago

it is happening with any dotted annotation...

    - kind: Secret
      name: my-secret
      valuesKey: some-key
      targetPath: test.aaa\.bbb
hiddeco commented 2 years ago

The validation rule in the chart is indeed incorrect and missing escapes, please open an issue there.

as42sl commented 2 years ago

ok thank you!