← Back to Pull requests

feat: label the CRD with its managing installation and guard duplicat… #440

Open
unknown opened this pull request with 320 lines diff across 4 files
View on GitHub
unknown unknown commented on Aug 22, 2026 15:05 UTC
Author

Summary


Stamps the NodeReadinessRule CRD with a managed-by label naming the installation that owns it, and refuses a fresh helm install when the CRD already exists.

Design notes


Why the CRD carries the label. It's cluster scoped and singleton, so it's the one artifact every install flow contends over. It's set with a controller-gen marker, so make manifests regenerates it in config/crd/bases, and verify-chart-drift.sh diffs that against the chart's crds/ copy to catch the two drifting apart.

Why a template guard, not a pre-install hook. The Helm guard uses lookup + fail in a template — same outcome without a ServiceAccount, ClusterRole or image, and it aborts at render time so the guidance lands in the terminal rather than Job logs.

Why it's keyed on .Release.IsInstall plus CRD existence, not the label value. Both installs may be carrying the default value, and that's precisely the accident being guarded against, so a value comparison would pass straight through it. Upgrades skip the check naturally.

Two things worth a reviewer's attention

Label is CRD-only. Helm 3 forces managed-by: Helm on resources it owns, so stamping the Deployment/RBAC/Services doesn't stick. The CRD works because Helm neither templates nor tracks crds/.

Guard only covers helm install. kubectl apply, kustomize and the static-pod path have none. A controller startup check would close the gap, but it's ruled out by alternative (1) in the issue — left out and documented. Happy to reconsider.

Also included


Chart-rendered NodeReadinessRule CRs now get the standard chart labels, which they were missing. Unrelated tidy-up, happy to split it out.

Related Issue


Fixes #438

Type of Change


/kind feature

Testing


  • helm install into a clean cluster: CRD is created with app.kubernetes.io/managed-by=node-readiness-controller.

  • helm install with a second release name while the CRD exists: render aborts with the guidance message, nothing is applied.

  • helm upgrade on the existing release: check is skipped, upgrade succeeds.

  • helm template output diffed against dist/crds.yaml; verify-chart-drift.sh passes.
  • Checklist


  • make test passes

  • make lint passes
  • Does this PR introduce a user-facing change?


    Yes

    ``release-note
    helm install now fails when a NodeReadinessRule CRD from another installation is already present in the cluster. The CRD carries a managed-by label identifying the owning installation.
    ``

    Diff: 320 lines (+240 / -80) across 4 files Reviewer: ajaysundark Review duration: 63937m
    All Vouch review confidence checks passed
    Residual risk 0.27 = Change Risk (0.49) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.49 · 320 lines diff across 4 files
    0.49
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    44%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.345
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #440"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 44.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 48.9% (MEDIUM) · Higher = larger blast radius
    48.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 44.7% · Lower = rushed or shallow review
    44.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.1% · Safe to merge
    27.1%