Skip to content

charts: render each label and pod annotation key once - #1035

Draft
marcleblanc2 wants to merge 1 commit into
marc/ci-kustomize-duplicate-keysfrom
marc/dedupe-labels
Draft

marcleblanc2 wants to merge 1 commit into
marc/ci-kustomize-duplicate-keysfrom
marc/dedupe-labels

Conversation

@marcleblanc2

@marcleblanc2 marcleblanc2 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Problem

A label or pod annotation key set both globally (sourcegraph.labels, sourcegraph.podLabels, sourcegraph.podAnnotations) and per component (<component>.labels, .podLabels, .podAnnotations) is rendered twice in one map. Helm keeps the last one, so helm install works, but kustomize rejects the manifest. This is the last row of the Problem table in #1034, and the reason kustomizeRender_labelOverrides.yaml fails there.

Stacked on #1034. The kustomize render check still fails on this PR because of the three template bugs that #1036 fixes.

Solution

  • Add a sourcegraph.mergedMaps helper to each chart's _helpers.tpl. It merges a list of maps, with later maps winning, and renders each key once.
  • Render the global and component maps through it in every workload of the sourcegraph, sourcegraph-migrator, sourcegraph-executor-k8s, and sourcegraph-executor-dind charts, and in the otel-collector Service. Each 6-line if/toYaml pair becomes one line.
  • The merge order matches the old rendering order, so the value Helm used before is the value rendered now. Helm releases deploy the same objects.
  • Add kustomizeRender_labelOverrides.yaml to the migrator and both executor charts, so the check covers them too.

Out of scope: a user label that repeats a key the chart sets itself, such as deploy or app, is still rendered twice. Nobody should set those, and fixing it means rewriting every chart-owned label and annotation.

Checklist

Test plan

Linked PRs

Amp threads

A key set both globally (sourcegraph.labels, podLabels, podAnnotations)
and per component was rendered twice in one map. Helm keeps the last one,
but kustomize rejects the manifest.

Add a sourcegraph.mergedMaps helper to each chart, which merges the maps
with later ones winning, and render the global and component maps through
it. The merge order matches the old rendering order, so Helm releases
render the same objects.

Add kustomizeRender_labelOverrides.yaml to the migrator and executor
charts, so the kustomize render check covers them too.

Amp-Thread-ID: https://ampcode.com/threads/T-01a2140d-bf64-751f-9812-0c8757baf6fd
Co-authored-by: Amp <amp@ampcode.com>
@marcleblanc2
marcleblanc2 added this pull request to stack #1037 November 25, 2026 21:44
@github-actions

Copy link
Copy Markdown

This branch has not been deployed

No deployments
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.

1 participant