← Back to Pull requests

AUTOSCALE-947: feat: migrate EC2NodeClass controller from HyperShift #43

Closed
unknown closed this pull request without merging on Oct 05, 2026 09:32 UTC
View on GitHub
unknown unknown commented on Sep 23, 2026 14:08 UTC
Author

Related hypershift PR: https://github.com/openshift/hypershift/pull/9746

Reconcile OpenshiftEC2NodeClasses in the hosted cluster into EC2NodeClasses, consuming the user data Secrets and AMI labels produced by the HyperShift Karpenter adapter. The finalizer, VAP and karpenter-subnets ConfigMap names match HyperShift so clusters can switch from the embedded operator.

The operator now owns the OpenshiftEC2NodeClass CRD, generated from api/karpenter and installed only in management-cluster mode on AWS.
Platforms expose hosted control plane NodeClass support through CloudProvider.HCPNodeClassProvider.

Bump github.com/openshift/hypershift/api for the AWS resource tag override policy types.

I also ran go fix on the package to modernize the code but otherwise made no changes to make the review and diff smaller.
IMO the code should be refactored in a follow up.

AI also found a bug in the HCP predicate (see the separate commit).

Changes of the EC2 controller related files


Excluding the changes from go fix:

  • karpenter_util: CRD import name

  • karpenter_util_test: CRD import name and table tests using map instead of struct { name string }

  • ec2_nodeclass_controller

  • - add constructor and Name() string func for the interface so that the generic controller setup can create this one for AWS and Azure
    - remove CRD reconciliation as the CRD controller is doing that
    - KO's default client is for the mgmt cluster not the hosted cluster -> update the watches etc.
    - ownership handling is done via controllerutil.SetControllerReference instead of the custom helper in hypershift go
    - use controllerutil.CreateOrUpdate directly instead of the hypershift helper
    - extract a few userdata specific functions, see below
  • ec2_nodeclass_controller_test

  • - Added TestReconcile and TestReconcileStatusPreservesIgnitionOwnedFields test
    - table tests using a map[string]struct{...}
    - extract duplicate labels or selectors we also use in the default nodeclass controller
  • userdata: extracted a few functions from the ec2_nodeclass_controller that are userdata related

  • userdata_test

  • - extract TestGetUserDataSecret and TestAMISelectorTermsFromUserDataSecret from the ec2_nodeclass_controller_test.go

    Diff: 283 lines (+212 / -71) across 3 files Reviewer: maxcao13 Review duration: 17003m
    All Vouch review confidence checks passed
    Residual risk 0.25 = Change Risk (0.63) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.63 · 283 lines diff across 3 files
    0.63
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    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.338
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.063
    Real PR Conversation Timeline
    1 comments
    "Review active on #43"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed sensitive_module
    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: 62.9% (MEDIUM) · Higher = larger blast radius
    62.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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 24.9% · Safe to merge
    24.9%