← Back to Pull requests

fix(webhook): validate Spark UI and driver ingress Service fields at admission #3298

Open
unknown opened this pull request with 378 lines diff across 4 files
View on GitHub
unknown unknown commented on Nov 08, 2026 14:38 UTC
Author

Purpose of this PR

Fixes #3297

The controller copies the Service fields of sparkUIOptions and driverIngressOptions into 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:

  • Add validateServiceOptions in a new internal/webhook/service_validator.go file and call it from the validateSpec function.

  • Check the servicePort, servicePortName, serviceType, serviceLabels and serviceAnnotations fields for sparkUIOptions and for each driverIngressOptions entry, using the IsValidPortNum, IsDNS1123Label, ValidateLabels and ValidateAnnotations helpers from apimachinery.

  • Accept only the ClusterIP, NodePort and LoadBalancer types for the serviceType field, since an ExternalName Service also needs a spec.externalName value, which the controller does not set.
  • Change Category

  • Bugfix (non-breaking change which fixes an issue)

  • Feature (non-breaking change which adds functionality)

  • Breaking change (fix or feature that could affect existing functionality)

  • Documentation update
  • 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.go at one call.

    Checklist

  • I have conducted a self-review of my own code.

  • I have updated documentation accordingly.

  • I have added tests that prove my changes are effective or that my feature works.

  • Existing unit tests pass locally with my changes.
  • Additional Notes

    TestSparkApplicationValidatorValidateCreate_ServiceOptions covers one valid configuration and eight invalid values across both option blocks. With the call to validateServiceOptions removed, all eight invalid cases fail and the valid case still passes. go test passes 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 -->

    Diff: 378 lines (+283 / -95) across 4 files Reviewer: harshrajdebug Review duration: 35477m
    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
    0.43
    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%
    46%
    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.355
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #3298"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.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: 42.9% (MEDIUM) · Higher = larger blast radius
    42.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: 46.7% · Lower = rushed or shallow review
    46.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: 22.9% · Safe to merge
    22.9%