fix(webhook): validate Spark UI and driver ingress Service fields at admission #3298
All Vouch review confidence checks passed
Residual risk 0.23 = Change Risk (0.43) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 378 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 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.355
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #3298"
general
weight: 0.35
harshrajdebug
Purpose of this PR
Fixes #3297
The controller copies the Service fields of
sparkUIOptionsanddriverIngressOptionsinto the Services it creates, but none of them was validated. A value the API server rejects made every submitted reconcile fail before the status was saved, and the application stayed SUBMITTED after the driver finished.Proposed changes:
validateServiceOptionsin a newinternal/webhook/service_validator.gofile and call it from thevalidateSpecfunction.sparkUIOptionsand for eachdriverIngressOptionsentry, using the IsValidPortNum, IsDNS1123Label, ValidateLabels and ValidateAnnotations helpers from apimachinery.Change Category
Rationale
This follows #2711, which moved the invalid name case from a failed reconcile to an admission error. The port, port name, label and annotation checks are the ones the API server runs on the Service. The type check is stricter only for ExternalName, which the controller cannot create. The new code is in its own file to keep the change to
sparkapplication_validator.goat one call.Checklist
Additional Notes
TestSparkApplicationValidatorValidateCreate_ServiceOptionscovers one valid configuration and eight invalid values across both option blocks. With the call tovalidateServiceOptionsremoved, all eight invalid cases fail and the valid case still passes.go testpasses for the webhook, sparkapplication controller and util packages with envtest, and golangci-lint v2.1.6 reports 0 issues on the webhook package.<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
Summary by CodeRabbit
Bug Fixes
Spark application and scheduled application settings now report invalid Spark UI service port names at the relevant field.
Whitespace around numeric Spark UI port values is now ignored when parsing.
New Features
Validation now covers Spark UI and driver ingress service and ingress settings, including ports, service types, labels, annotations, TLS hosts, and secret names.
Load-balancer source-range annotations are validated for compatible service types and CIDR format.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->