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

[Bug] Duplicate labels because of unsafe use of merge #1306

Closed
kuznero opened this issue Nov 16, 2023 · 1 comment
Closed

[Bug] Duplicate labels because of unsafe use of merge #1306

kuznero opened this issue Nov 16, 2023 · 1 comment
Labels
bug Something isn't working triage/duplicate Indicates an issue is a duplicate of other open issue.

Comments

@kuznero
Copy link

kuznero commented Nov 16, 2023

Describe the bug

Templates produce duplicate labels because of unsafe use of merge.

Version

v5.4.2

To Reproduce

Run helm template -f values.yaml . from the root of the chart folder and notice repetitive labels in deployment resource.

Expected behavior

Should have no duplicates in labels.

Suspect component/Location where the bug might be occurring

In rbac.yaml:

  {{- with (merge $.Values.additionalLabels (include "grafana-operator.labels" $ | fromYaml)) }}
  labels:
    {{- toYaml . | nindent 4 }}
  {{- end }}

The fix is to make a deep copy of .Values.additionalLabels before calling merge:

  {{- $additionalLabelsCopy := deepCopy $.Values.additionalLabels }}
  {{- with (merge $additionalLabelsCopy (include "grafana-operator.labels" $ | fromYaml)) }}
  labels:
    {{- toYaml . | nindent 4 }}
  {{- end }}

Runtime (please complete the following information):

  • OS: Linux (Debian 12)
  • Grafana Operator Version [e.g. v5.4.2]
  • Environment: Kubernetes
  • Deployment type: deployed
  • Other: deploying using fluxcd
@kuznero kuznero added bug Something isn't working needs triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Nov 16, 2023
@weisdd weisdd added triage/duplicate Indicates an issue is a duplicate of other open issue. and removed needs triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Nov 17, 2023
@weisdd
Copy link
Collaborator

weisdd commented Nov 17, 2023

I believe it was first reported in #1298 and fixed in #1299, which will be part of the upcoming release. So, I'm going to close the issue.
Though, thanks for reporting!

@weisdd weisdd closed this as completed Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage/duplicate Indicates an issue is a duplicate of other open issue.
Projects
None yet
Development

No branches or pull requests

2 participants