mimir icon indicating copy to clipboard operation
mimir copied to clipboard

Helm: mimir-distributed value `externalConfigVersion` must be quoted when rendered

Open pdf opened this issue 3 years ago • 5 comments

Describe the bug

The default externalConfigVersion value is '0', which suggests that numeric values as strings should work correctly, however the value is rendered unquoted by the template helper, resulting in the following output:

annotations:
  checksum/config: 0

Annotation values must be strings.

To Reproduce

  1. Deploy mimir-distributed helm chart with useExternalConfig: true.
  2. Deployment is rejected due to malformed annotations.

Expected behavior

The externalConfigVersion value should be rendered enclosed in quotes:

annotations:
  checksum/config: "0"

Environment

  • Infrastructure: Kubernetes
  • Deployment tool: helm

Additional Context

Helm error:

failed to create resource: Deployment in version "v1" cannot be handled as a Deployment: json: cannot unmarshal number into Go struct field ObjectMeta.spec.template.metadata.annotations of type string

pdf avatar Jul 01 '22 04:07 pdf

Facing the same issue here. Is there any work around ?

nasirudheen avatar Jul 01 '22 10:07 nasirudheen

Yes, you can use a value that can only be interpreted as stringish, ie - aaa instead of '0'

pdf avatar Jul 01 '22 10:07 pdf

But checksum/config is autogenerated. So will have to modify the templates, right ?

nasirudheen avatar Jul 01 '22 10:07 nasirudheen

This issue only applies when you have useExternalConfig enabled, in which case the value of externalConfigVersion is used verbatim in the annotation. Otherwise, the annotation contains a hash of the config contents, which should be a long string value, though quoting the hash wouldn't hurt either.

pdf avatar Jul 01 '22 11:07 pdf

Ohhh...Thanks indeed for that ! I quoted the externalConfigVersion with some strings and it works ! Appreciate your help !

nasirudheen avatar Jul 01 '22 11:07 nasirudheen

+1

ToonTijtgat2 avatar Oct 11 '23 13:10 ToonTijtgat2

I am not convinced this should be a concern of the mimir-distributed chart. This is a general rule for kubernetes annotations (See first Note in docs). I don't think you should get different validation for annotations on an nginx deployed via this chart vs an nginx deployed via any other chart or an nginx deployed without helm.

dimitarvdimitrov avatar Oct 16 '23 18:10 dimitarvdimitrov

@dimitarvdimitrov you misunderstand the problem - when a string value is provided that contains content that can be interpreted as a number, it is rendered as numeric, not as the original string.

pdf avatar Oct 16 '23 19:10 pdf

thanks for clarifying; i opened a PR to fix this https://github.com/grafana/mimir/pull/6407

dimitarvdimitrov avatar Oct 17 '23 11:10 dimitarvdimitrov