Skip to content

fix/opentelemetry: Restart otel-collector when its config changes - #1043

Merged
DaedalusG merged 2 commits into
mainfrom
fix-otel-collector-checksum
Dec 1, 2026
Merged

DaedalusG merged 2 commits into
mainfrom
fix-otel-collector-checksum

Conversation

@DaedalusG

@DaedalusG DaedalusG commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Context

Problem

  • On Sourcegraph Cloud, every instance that renders the new insiders chart gets the label and the fixed ConfigMap in the same apply, without a pod restart, so critical_otel-collector_pods_available_percentage pages. This happened to about 33 instances this morning.
  • A second wave started at 16:01 UTC after the controller upgrade reconciled instances that were still on the pre-sourcegraph: render opt-in labels on every object, each key once #1038 chart (morgan-stanley-labs, miovision, typeform, dropbox, depop so far). At 11:56 UTC, 74 instances were still on the old chart. Restarting their collectors does not help until they reconcile, so each one would need a restart timed after its reconcile.

Solution

  • Add a checksum/otel-collector-config pod annotation that hashes openTelemetry.gateway.config.traces (per review; like the pgsql auth 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.
  • Every otel-collector Deployment 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.
  • New test should roll the pod when the collector config changes pins the hash, computed independently as the sha256 of the merged traces values in sorted-key JSON. It fails on main's template (1 failed, 3 passed) and passes with this change.
  • ./scripts/helm-docs.sh makes no changes.

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>
@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

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 }}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 }}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

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>
@DaedalusG
DaedalusG marked this pull request as ready for review December 1, 2026 17:35
@DaedalusG
DaedalusG merged commit 814ddbc into main Dec 1, 2026
7 checks passed
@DaedalusG
DaedalusG deleted the fix-otel-collector-checksum branch December 1, 2026 17:35
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.

2 participants