Repository navigation
charts: render each label and pod annotation key once - #1035
Draft
marcleblanc2 wants to merge 1 commit into
Draft
marcleblanc2 wants to merge 1 commit into
marcleblanc2 wants to merge 1 commit into
Conversation
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>
2 of 3 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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, sohelm installworks, but kustomize rejects the manifest. This is the last row of the Problem table in #1034, and the reasonkustomizeRender_labelOverrides.yamlfails there.Stacked on #1034. The kustomize render check still fails on this PR because of the three template bugs that #1036 fixes.
Solution
sourcegraph.mergedMapshelper to each chart's_helpers.tpl. It merges a list of maps, with later maps winning, and renders each key once.sourcegraph,sourcegraph-migrator,sourcegraph-executor-k8s, andsourcegraph-executor-dindcharts, and in theotel-collectorService. Each 6-lineif/toYamlpair becomes one line.kustomizeRender_labelOverrides.yamlto 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
deployorapp, is still rendered twice. Nobody should set those, and fixing it means rewriting every chart-owned label and annotation.Checklist
sourcegraphandsourcegraph-executorTest plan
kustomizeRender_*.yamlon ci: render charts with exhaustive test values through kubeconform and kustomize #1034 and on this PR, parsed both outputs with duplicate keys resolved last-wins (as Helm does), and compared them: identical for every file that renders. charts: fix three templates that fail to render when their value is set #1036 repeats this for theallValuesfiles, which only render once its fixes are in.kustomizeRender_labelOverrides.yamlfails kustomize on ci: render charts with exhaustive test values through kubeconform and kustomize #1034 and passes here, in all 4 charts. In the rendered frontend Deployment,example.com/teamappears once, with the frontend value.scripts/ci/kustomize-render.shnow fails only on the three files the template bugs in charts: fix three templates that fail to render when their value is set #1036 break.helm unittest(281 tests) andscripts/ci/lint.shpass, and./scripts/helm-docs.shchanges nothing.Linked PRs
sourcegraph.mergedLabelshelper for PVC, ServiceAccount, and RBAC labels. Whichever merges second should switch to the other's helper.Amp threads