๐ Reject removal of a secondary control plane load balancer instead of panicking #6130
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
Model 2 ยท Review Depth (DistilBERT)
Depth Score: 0.17 ยท 1 substantive comment(s)
Model 3 ยท Review Timing & Attention
Session adequacy: 100% ยท Reviewer familiarity: 35%
Bedrock Claude 3 ยท Risk Narration
(disconnected)
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
nrb
What type of PR is this?
/kind bug
What this PR does / why we need it:
This PR prevents the
AWSClustervalidating webhook from panicking when an update attempts to remove a previously configuredspec.secondaryControlPlaneLoadBalancer.ValidateUpdatevalidates 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:
The helper entered the existing-load-balancer branch and dereferenced
newlb, for example throughnewlb.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; andadds a regression test covering the
oldlb != nil, newlb == nilcase.This is the mirror of #5247, fixed by #5248, which covered adding a secondary control plane load balancer where
oldlb == nilandnewlb != 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.Invaliderror; andincludes a status cause whose
Fieldis exactlyspec.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:
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
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.