Repository navigation
fix/opentelemetry: Restart otel-collector when its config changes - #1043
Merged
Merged
Conversation
The collector reads its config only at startup, and nothing in its pod template changed with the ConfigMap, so #1039's fix never reached running collectors while #1038's Service label made their failing scrape fire the otel-collector pods-available alert. Hash the rendered ConfigMap into a pod annotation, like checksum/jaeger-config, so a config change rolls the pod. Amp-Thread-ID: https://ampcode.com/threads/T-0663d63f-0fe9-4e5d-b765-d41e340cff02 Co-authored-by: Amp <amp@ampcode.com>
michaellzc
reviewed
Dec 1, 2026
| annotations: | ||
| kubectl.kubernetes.io/default-container: otel-collector | ||
| # The collector reads its config only at startup, so roll the pod when it changes. | ||
| checksum/otel-collector-config: {{ include (print $.Template.BasePath "/otel-collector/otel-collector.ConfigMap.yaml") . | sha256sum }} |
Member
There was a problem hiding this comment.
Suggested change
| checksum/otel-collector-config: {{ include (print $.Template.BasePath "/otel-collector/otel-collector.ConfigMap.yaml") . | sha256sum }} | |
| checksum/otel-collector-config: {{ toJson .Values.openTelemetry.gateway.config.traces | sha256sum }} |
Contributor
Author
There was a problem hiding this comment.
Applied in f882073: the annotation now hashes toJson .Values.openTelemetry.gateway.config.traces, and the ConfigMap test plumbing is gone. The incident fix still holds, because the annotation is new and every collector rolls once on its first reconcile with this chart. Tradeoff: a later change to the chart's collector config template with the same values, like #1039, will not roll pods on its own. helm unittest: 318/318 pass, and the new test pins the hash computed independently from the merged defaults (it fails on main).
michaellzc
approved these changes
Dec 1, 2026
Simpler than including the ConfigMap template: no test suite needs to load it. The annotation is new, so every collector still rolls once on upgrade. Amp-Thread-ID: https://ampcode.com/threads/T-0663d63f-0fe9-4e5d-b765-d41e340cff02 Co-authored-by: Amp <amp@ampcode.com>
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.
Context
otel-collectorconfig so its own metrics are served on0.0.0.0:8888, and sourcegraph: render opt-in labels on every object, each key once #1038 addedapp: otel-collectorto the Service, which makes theotel-collector"pods available" alert see that scrape target.127.0.0.1:8888), so the scrape fails and the critical alert fires.Problem
critical_otel-collector_pods_available_percentagepages. This happened to about 33 instances this morning.Solution
checksum/otel-collector-configpod annotation that hashesopenTelemetry.gateway.config.traces(per review; like thepgsqlauth checksums). The annotation is new, so the reconcile that brings this chart rolls every collector onto the fixed config, with no manual restarts. Later, a change to the traces values rolls the pods. A change to the chart's config template alone, with the same values, does not.otel-collectorDeployment rolls once on the upgrade that adds the annotation.Checklist
Test plan
helm unittest ./charts/sourcegraph(helm-unittest v1.0.2, as in CI): 46 suites and 318 tests pass, plus all snapshots.should roll the pod when the collector config changespins the hash, computed independently as the sha256 of the mergedtracesvalues in sorted-key JSON. It fails onmain's template (1 failed, 3 passed) and passes with this change../scripts/helm-docs.shmakes no changes.