โ† Back to Pull requests

๐Ÿ› Reject removal of a secondary control plane load balancer instead of panicking #6130

Closed
unknown closed this pull request without merging on Jul 24, 2026 15:39 UTC
View on GitHub
unknown unknown commented on Jul 18, 2026 17:06 UTC
Author

What type of PR is this?

/kind bug

What this PR does / why we need it:

This PR prevents the AWSCluster validating webhook from panicking when an update attempts to remove a previously configured spec.secondaryControlPlaneLoadBalancer.

ValidateUpdate validates old/new pairs for the primary and secondary control plane load balancer specifications. It skips a pair only when both values are nil.

Before this change, when an existing secondary load balancer configuration was removed, the validation helper received:

oldlb != nil
newlb == nil

The helper entered the existing-load-balancer branch and dereferenced newlb, for example through newlb.LoadBalancerType, causing a nil pointer panic. The HTTP server recovered the individual request, but the admission request failed with an internal webhook error instead of returning a normal validation response.

This change:

detects an attempted removal before dereferencing newlb;
returns a clear, field-scoped validation error instead of panicking;
passes the field path for each load balancer into the validation helper, so validation errors are attributed to the correct primary or secondary load balancer field instead of always being reported under controlPlaneLoadBalancer; this also corrects the existing behavior where immutable-field errors for the secondary load balancer were incorrectly reported against the primary load balancer path; and
adds a regression test covering the oldlb != nil, newlb == nil case.

This is the mirror of #5247, fixed by #5248, which covered adding a secondary control plane load balancer where oldlb == nil and newlb != nil.

This PR intentionally does not add support for deleting an existing secondary control plane load balancer. Supporting removal would also require controller-side reconciliation and cleanup of the corresponding AWS resources, which is outside the scope of this webhook robustness fix.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):

Fixes #6129

Special notes for your reviewer:

The change is limited to update validation and its regression coverage. It does not modify the API schema, defaulting behavior, or AWS resource reconciliation.

The regression test verifies that attempting to remove an existing secondary control plane load balancer:

does not panic;
returns a structured apierrors.Invalid error; and
includes a status cause whose Field is exactly spec.secondaryControlPlaneLoadBalancer, rather than relying only on substring matching of the rendered error message.

No e2e test is added because the failure is fully reproducible in webhook validation and does not require an AWS environment.

Testing performed:

make test

AI Usage:

Claude Code was used to help analyze the failure mode, adversarially review the proposed behavior, and refine the issue and pull request descriptions. All code changes and tests were manually reviewed and validated by the author.

Checklist:

[x] squashed commits
[ ] includes documentation
[x] includes AI generated content
[x] includes emoji in title
[x] adds unit tests

  • adds or updates e2e tests
  • Release note:

    ``release-note
    Prevented the AWSCluster validating webhook from panicking when removal of an existing secondary control plane load balancer is attempted. The update now returns a clear validation error.
    ``

    Diff: 446 lines (+334 / -112) across 5 files Reviewer: nrb Review duration: 8553m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.45) ร— (1 โˆ’ Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 ยท Change Risk (XGBoost)
    Score: 0.45 ยท 446 lines diff across 5 files
    0.45
    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.365
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #6130"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 45.4% (MEDIUM) ยท Higher = larger blast radius
    45.4%
    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: 17.9% ยท Safe to merge
    17.9%