Skip to content

fix: use otel selector labels instead of regular labels for proper trace wiring#40

Merged
adityachoudhari26 merged 1 commit intomainfrom
correct-otel-label
May 4, 2026
Merged

fix: use otel selector labels instead of regular labels for proper trace wiring#40
adityachoudhari26 merged 1 commit intomainfrom
correct-otel-label

Conversation

@adityachoudhari26
Copy link
Copy Markdown
Member

@adityachoudhari26 adityachoudhari26 commented May 4, 2026

Summary by CodeRabbit

  • Version Updates

    • Main Helm chart bumped to v1.1.2
    • OpenTelemetry sub-chart bumped to v0.2.1
  • Improvements

    • Standardized Kubernetes selector labels for OpenTelemetry DaemonSet, Deployment, and Service components
  • Tests

    • Added test suite validating selector label stability across chart versions

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

📝 Walkthrough

Walkthrough

The pull request updates the OTEL subchart to standardize Kubernetes resource selectors across DaemonSet, Deployment, and Service templates. Instead of combining ctrlplane.selectorLabels and otel.labels, all resources now use only otel.selectorLabels. Chart versions are incremented, and a new test suite validates selector label stability.

Changes

OTEL Selector Label Standardization

Layer / File(s) Summary
Version Bumps
charts/ctrlplane/Chart.yaml, charts/ctrlplane/charts/otel/Chart.yaml
Parent chart version incremented 1.1.1 → 1.1.2; OTEL subchart version incremented 0.2.0 → 0.2.1.
Template Selector Refactoring
charts/ctrlplane/charts/otel/templates/daemonset.yaml, charts/ctrlplane/charts/otel/templates/deployment.yaml, charts/ctrlplane/charts/otel/templates/service.yaml
spec.selector.matchLabels / spec.selector changed from combining ctrlplane.selectorLabels and otel.labels to using otel.selectorLabels only, ensuring consistent label matching across resources.
Test Suite
charts/ctrlplane/tests/otel_selector_test.yaml
New Helm test suite validates that DaemonSet, Deployment, and Service selectors contain only stable identity labels (app.kubernetes.io/name, app.kubernetes.io/instance), while pod template labels retain additional chart/app labels.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • jsbroks
  • zacharyblasczyk

Poem

🐰 Hop! The selectors now align,
One stable label does define,
No more mixing here and there,
OTEL's pods match with proper care!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: fixing otel selector labels in Kubernetes manifests for proper trace wiring.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch correct-otel-label

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
charts/ctrlplane/tests/otel_selector_test.yaml (1)

1-55: 💤 Low value

Test suite looks solid — one minor nit on configmap.yaml inclusion.

The structure is correct: equal on spec.selector.matchLabels/spec.selector catches exact label drift, the pod-template test guards against accidentally removing version labels from pod metadata, and the deployment test correctly gates on otel.workload.kind: Deployment to satisfy the template condition.

The only nit: configmap.yaml (line 6) is listed in suite-level templates but is never the target of any test case. If it's only there to satisfy rendering dependencies, it's harmless, but if it's unused, it adds noise.

♻️ Remove if no rendering dependency requires it
 templates:
   - charts/otel/templates/daemonset.yaml
   - charts/otel/templates/deployment.yaml
   - charts/otel/templates/service.yaml
-  - charts/otel/templates/configmap.yaml
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@charts/ctrlplane/tests/otel_selector_test.yaml` around lines 1 - 55, The
tests include "configmap.yaml" in the suite-level templates list but no test
targets it; either remove "configmap.yaml" from the suite templates to avoid
noise (if it was only included for rendering and isn’t required), or add a
focused test case that targets the configmap template (e.g., an asserts block
validating expected keys/values) so the inclusion is purposeful; locate the
templates array in otel_selector_test.yaml and update it or add a new test entry
referencing configmap.yaml accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@charts/ctrlplane/charts/otel/templates/daemonset.yaml`:
- Around line 16-18: The DaemonSet's spec.selector.matchLabels has been changed
(the selector is rendered via the template include "otel.selectorLabels"), but
spec.selector is immutable after creation which will cause helm upgrade
failures; update release notes/NOTES.txt and CHANGELOG to clearly document this
breaking change and required pre-upgrade steps (e.g., run helm upgrade --force
or kubectl delete daemonset <name> --cascade=orphan) and include the exact error
message example; additionally, avoid changing the selector in future releases by
keeping the include "otel.selectorLabels" output stable or bumping chart major
version if selector must change.

In `@charts/ctrlplane/charts/otel/templates/deployment.yaml`:
- Around line 23-25: Deployment spec.selector.matchLabels is immutable and
changing the labels generated by the otel.selectorLabels template will break
upgrades; ensure the chart does not alter existing selector labels for resources
of kind Deployment (keep the output of include "otel.selectorLabels" unchanged
between releases) and, if a selector change is unavoidable, add explicit upgrade
notes documenting the required pre-upgrade mitigation (use --force or delete the
Deployment manually) so operators know to perform the manual migration before
upgrading.

---

Nitpick comments:
In `@charts/ctrlplane/tests/otel_selector_test.yaml`:
- Around line 1-55: The tests include "configmap.yaml" in the suite-level
templates list but no test targets it; either remove "configmap.yaml" from the
suite templates to avoid noise (if it was only included for rendering and isn’t
required), or add a focused test case that targets the configmap template (e.g.,
an asserts block validating expected keys/values) so the inclusion is
purposeful; locate the templates array in otel_selector_test.yaml and update it
or add a new test entry referencing configmap.yaml accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bb817edd-29f2-4e23-b585-bf3661fb49ab

📥 Commits

Reviewing files that changed from the base of the PR and between 03fe98e and 17195da.

⛔ Files ignored due to path filters (1)
  • charts/ctrlplane/Chart.lock is excluded by !**/*.lock
📒 Files selected for processing (6)
  • charts/ctrlplane/Chart.yaml
  • charts/ctrlplane/charts/otel/Chart.yaml
  • charts/ctrlplane/charts/otel/templates/daemonset.yaml
  • charts/ctrlplane/charts/otel/templates/deployment.yaml
  • charts/ctrlplane/charts/otel/templates/service.yaml
  • charts/ctrlplane/tests/otel_selector_test.yaml

Comment on lines 16 to +18
selector:
matchLabels:
{{- include "ctrlplane.selectorLabels" $ | nindent 6 }}
{{- include "otel.labels" . | nindent 6 }}
{{- include "otel.selectorLabels" . | nindent 6 }}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Breaking upgrade: spec.selector.matchLabels is immutable on DaemonSet.

spec.selector is an immutable field on Kubernetes DaemonSets (and Deployments) after initial creation. A helm upgrade from the previous chart version will fail with:

The DaemonSet "<name>" is invalid: spec.selector: Invalid value: ... field is immutable

This affects any cluster currently running the prior chart version. Required pre-upgrade action (one of):

  • helm upgrade --force — triggers delete + re-create (causes brief downtime/pod disruption).
  • Manual deletionkubectl delete daemonset <name> --cascade=orphan before running helm upgrade.

This should be called out in NOTES.txt, a CHANGELOG, or upgrade documentation to prevent operators from being caught off-guard.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@charts/ctrlplane/charts/otel/templates/daemonset.yaml` around lines 16 - 18,
The DaemonSet's spec.selector.matchLabels has been changed (the selector is
rendered via the template include "otel.selectorLabels"), but spec.selector is
immutable after creation which will cause helm upgrade failures; update release
notes/NOTES.txt and CHANGELOG to clearly document this breaking change and
required pre-upgrade steps (e.g., run helm upgrade --force or kubectl delete
daemonset <name> --cascade=orphan) and include the exact error message example;
additionally, avoid changing the selector in future releases by keeping the
include "otel.selectorLabels" output stable or bumping chart major version if
selector must change.

Comment on lines 23 to +25
selector:
matchLabels:
{{- include "ctrlplane.selectorLabels" $ | nindent 6 }}
{{- include "otel.labels" . | nindent 6 }}
{{- include "otel.selectorLabels" . | nindent 6 }}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Same immutable selector breaking change applies to Deployment.

spec.selector.matchLabels is immutable on Deployments post-creation. Clusters using workload.kind: Deployment will experience the same upgrade failure described for the DaemonSet. The same pre-upgrade mitigation applies (--force or manual deletion), and both cases should be covered in upgrade notes.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@charts/ctrlplane/charts/otel/templates/deployment.yaml` around lines 23 - 25,
Deployment spec.selector.matchLabels is immutable and changing the labels
generated by the otel.selectorLabels template will break upgrades; ensure the
chart does not alter existing selector labels for resources of kind Deployment
(keep the output of include "otel.selectorLabels" unchanged between releases)
and, if a selector change is unavoidable, add explicit upgrade notes documenting
the required pre-upgrade mitigation (use --force or delete the Deployment
manually) so operators know to perform the manual migration before upgrading.

@adityachoudhari26 adityachoudhari26 merged commit 402df97 into main May 4, 2026
4 checks passed
@adityachoudhari26 adityachoudhari26 deleted the correct-otel-label branch May 4, 2026 18:49
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