Skip to content

fix(openhab): align pod template labels#674

Open
mberlofa wants to merge 2 commits into
mainfrom
fix/openhab-template-standards
Open

fix(openhab): align pod template labels#674
mberlofa wants to merge 2 commits into
mainfrom
fix/openhab-template-standards

Conversation

@mberlofa

@mberlofa mberlofa commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Align openHAB StatefulSet pod template labels with immutable selector labels plus user podLabels.
  • Add fail-fast validation to prevent podLabels from overriding selector labels.
  • Add unit coverage for selector-label override validation.

Validation

  • helm unittest charts/openhab: 118 tests passed
  • helm lint --strict charts/openhab: passed
  • make template-standards-check CHART=openhab: passed
  • make standards-check CHART=openhab: passed
  • make standards-guard CHART=openhab: passed
  • node scripts/charts/validate-chart.js --chart openhab --no-k3d: static layers passed, including kubeconform and ah lint
  • k3d behavioral validation on k3d-helmforge-tests-wsl: default plus every ci/*.yaml passed sequentially
  • make site-sync-check CHART=openhab: passed
  • site npm run lint, npm run format:check, npm run build: passed
  • make release-check REPO=charts: passed with expected post-merge release warning
  • make attribution-check REPO=charts: passed

Site Sync

Site PR: helmforgedev/site#352

Summary by CodeRabbit

  • Bug Fixes
    • Added validation to prevent custom pod labels from overriding required selector labels, avoiding invalid StatefulSet output.
    • Updated pod label rendering to consistently use the selector labels set for pods.
  • Tests
    • Expanded validation tests to cover conflicts for both selector label keys (name and instance).
    • Added dedicated test values to confirm rendering fails with the expected error message when conflicts occur.

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2195370c-0d0b-4bdf-a385-301f8700af78

📥 Commits

Reviewing files that changed from the base of the PR and between aeff7ad and 3203b40.

📒 Files selected for processing (6)
  • charts/openhab/templates/_helpers.tpl
  • charts/openhab/templates/statefulset.yaml
  • charts/openhab/tests/podlabels-selector-combined-values.yaml
  • charts/openhab/tests/podlabels-selector-instance-values.yaml
  • charts/openhab/tests/podlabels-selector-name-values.yaml
  • charts/openhab/tests/validation_test.yaml
✅ Files skipped from review due to trivial changes (2)
  • charts/openhab/tests/podlabels-selector-combined-values.yaml
  • charts/openhab/tests/podlabels-selector-name-values.yaml
🚧 Files skipped from review as they are similar to previous changes (3)
  • charts/openhab/templates/statefulset.yaml
  • charts/openhab/tests/podlabels-selector-instance-values.yaml
  • charts/openhab/templates/_helpers.tpl

📝 Walkthrough

Walkthrough

Adds a Helm helper template that rejects podLabels overrides of app.kubernetes.io/name and app.kubernetes.io/instance, wires that check into the StatefulSet render path, switches pod template labels to selector labels, and adds validation fixtures and tests.

Changes

Pod Labels Validation

Layer / File(s) Summary
Validation helper and StatefulSet wiring
charts/openhab/templates/_helpers.tpl, charts/openhab/templates/statefulset.yaml
A new openhab.validatePodLabels helper fails rendering if podLabels sets either selector label key; the StatefulSet template includes this helper and switches pod template metadata labels from openhab.labels to openhab.selectorLabels.
Test fixtures and validation cases
charts/openhab/tests/podlabels-selector-combined-values.yaml, charts/openhab/tests/podlabels-selector-instance-values.yaml, charts/openhab/tests/podlabels-selector-name-values.yaml, charts/openhab/tests/validation_test.yaml
New values files define podLabels that override selector labels, and validation cases assert template rendering fails with the expected error messages.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Helm
  participant StatefulSetTemplate
  participant ValidatePodLabelsHelper

  Helm->>StatefulSetTemplate: render template
  StatefulSetTemplate->>ValidatePodLabelsHelper: include openhab.validatePodLabels
  ValidatePodLabelsHelper->>ValidatePodLabelsHelper: check podLabels for selector keys
  alt override detected
    ValidatePodLabelsHelper-->>Helm: fail with error message
  else no override
    ValidatePodLabelsHelper-->>StatefulSetTemplate: continue rendering
    StatefulSetTemplate->>StatefulSetTemplate: apply openhab.selectorLabels
  end
Loading

Related PRs: None found.

Suggested labels: enhancement, helm-chart, tests

Suggested reviewers: None identified.

Poem
A rabbit hopped through YAML fields so bright,
Guarding labels selector-tight,
"No overrides here!" it cried with glee,
StatefulSets rendered, safe and free,
Tests confirm the fail is right! 🐰✨

🚥 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 summarizes the main change: aligning the openHAB pod template labels.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/openhab-template-standards

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

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Standards Check (GR-079) — PASS

Every changed chart fully passes standards-check.

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

🟢 Security Scan: openhab

Framework Score
MITRE + NSA + SOC2 87.878784%

✅ Security posture acceptable.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
charts/openhab/tests/validation_test.yaml (1)

44-57: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider adding a combined-override test case.

Both new tests cover a single overridden key at a time. A test where podLabels sets both app.kubernetes.io/name and app.kubernetes.io/instance would confirm the helper fails fast on the first check (name) rather than silently passing due to ordering issues in future refactors.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@charts/openhab/tests/validation_test.yaml` around lines 44 - 57, Add a
combined override validation case for podLabels in validation_test.yaml, since
the current tests only cover app.kubernetes.io/name and
app.kubernetes.io/instance separately. Create a test alongside the existing
should fail when podLabels override selector name/instance cases that uses a
values file setting both selector labels at once, and assert the failure message
from the validation helper still trips on the first check in the relevant
template validation path.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@charts/openhab/tests/validation_test.yaml`:
- Around line 44-57: Add a combined override validation case for podLabels in
validation_test.yaml, since the current tests only cover app.kubernetes.io/name
and app.kubernetes.io/instance separately. Create a test alongside the existing
should fail when podLabels override selector name/instance cases that uses a
values file setting both selector labels at once, and assert the failure message
from the validation helper still trips on the first check in the relevant
template validation path.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c8d827d1-587b-4fbe-8bab-cc8c03105ea0

📥 Commits

Reviewing files that changed from the base of the PR and between 47bc2fc and aeff7ad.

📒 Files selected for processing (5)
  • charts/openhab/templates/_helpers.tpl
  • charts/openhab/templates/statefulset.yaml
  • charts/openhab/tests/podlabels-selector-instance-values.yaml
  • charts/openhab/tests/podlabels-selector-name-values.yaml
  • charts/openhab/tests/validation_test.yaml

@mberlofa mberlofa force-pushed the fix/openhab-template-standards branch from aeff7ad to 3203b40 Compare July 5, 2026 19:01
@mberlofa

mberlofa commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the CodeRabbit nitpick from the review body.

What changed:

  • Added podlabels-selector-combined-values.yaml with both selector labels overridden.
  • Added a validation test asserting the combined override still fails first on app.kubernetes.io/name.

Validation:

  • helm unittest charts/openhab -f tests/validation_test.yaml passed.
  • make validate-chart CHART=openhab passed after the final rebase: openhab: FULLY VALIDATED (21 layers), including all k3d behavioral scenarios.
  • make release-check REPO=charts passed with the expected GR-077 release-publication warning.
  • make attribution-check REPO=charts passed.

This CodeRabbit item was posted in the review body/top-level summary, not as an unresolved review thread, so there is no thread ID to reply to or resolve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant