Added SparkApp name validator to accept valid DNS-1035 format label names #2697
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 618 lines diff across 7 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.385
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #2697"
general
weight: 0.35
vjanelle
<!-- Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, check our contributor guidelines: https://www.kubeflow.org/docs/about/contributing
2. To know more about how to develop with the Spark operator, check the developer guide: https://www.kubeflow.org/docs/components/spark-operator/developer-guide/
3. If you want faster PR reviews, check how: https://git.k8s.io/community/contributors/guide/pull-requests.md#best-practices-for-faster-reviews
4. Please open an issue to discuss significant work before you start. We appreciate your contributions and don't want your efforts to go to waste!
-->
Purpose of this PR
This PR adds early validation of SparkApplication
metadata.nameto ensure it conforms to DNS-1035 label requirements (same as Kubernetes Service names). This prevents applications with invalid names from being accepted and failing later when the controller attempts to create the web UI Service.Problem:
Currently, SparkApplications with invalid names (e.g., starting with numbers like
28478459-kafka-to-gcs-streaming-6j783x) are accepted by the API server but fail during reconciliation with errors like:Solution:
Add webhook validation to reject invalid names at admission time with concise, user-friendly error messages.
Proposed changes:
validateName()function to check DNS-1035 label complianceValidateCreate()andValidateUpdate()webhook handlersChange Category
<!-- Indicate the type of change by marking the applicable boxes. -->
Rationale
Why this change is needed:
1. Early Failure Detection: Currently, invalid names are only detected when the controller tries to create Services, resulting in confusing errors long after submission.
2. Better User Experience: Users get immediate, clear feedback about naming requirements instead of delayed reconciliation errors.
3. Consistency: Ensures SparkApplication names follow Kubernetes naming conventions from the start, preventing downstream resource creation failures.
4. Reduced Confusion: The previous error messages were verbose and technical. The new messages are concise and explain the specific issue (e.g., "must start with a letter").
Impact:
Checklist
<!-- Before submitting your PR, please review the following: -->
Additional Notes
<!-- Include any additional notes or context that could be helpful for the reviewers here. -->
Error Message Examples:
"invalid SparkApplication name \"28478459-kafka-to-gcs-streaming-6j783x\": name must start with a letter (not a number)""invalid SparkApplication name \"...\": name exceeds 63 characters""invalid SparkApplication name \"...\": name must start with a lowercase letter"Valid Name Requirements:
my-job,job1,data-pipeline-01,a1Testing:
Related:
This validation prevents the same issue that would occur when creating the web UI Service during reconciliation, but catches it earlier with better error messages.