feat(webhook): Add webhook validation for SparkConnect CRD#2862
Conversation
There was a problem hiding this comment.
Pull request overview
Adds admission webhooks for the SparkConnect (v1alpha1) CRD to enforce server-side validation/defaulting similar to existing Spark CRDs, and wires the new webhooks into generated manifests and the Helm chart.
Changes:
- Registers
SparkConnectin the webhook scheme and starts mutating/validating webhooks for the CRD. - Implements
SparkConnectadmission validation rules (name, sparkVersion, image presence, dynamic allocation bounds, memory string format) plus a defaulter. - Adds unit tests for the validator and updates webhook manifests/Helm templates to include SparkConnect webhooks.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/scheme/scheme.go | Registers v1alpha1 types into the webhook scheme so defaults/webhooks can operate on SparkConnect. |
| internal/webhook/sparkconnect_validator.go | New SparkConnect validating webhook implementation. |
| internal/webhook/sparkconnect_defaulter.go | New SparkConnect mutating webhook (defaulting) implementation. |
| internal/webhook/sparkconnect_validator_test.go | New unit tests covering SparkConnect validation behaviors. |
| cmd/operator/webhook/start.go | Registers SparkConnect defaulter/validator with the webhook manager. |
| config/webhook/manifests.yaml | Adds generated webhook configuration entries for SparkConnect. |
| charts/spark-operator-chart/templates/webhook/validatingwebhookconfiguration.yaml | Helm: adds validating webhook entry for SparkConnect. |
| charts/spark-operator-chart/templates/webhook/mutatingwebhookconfiguration.yaml | Helm: adds mutating webhook entry for SparkConnect. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
8f8c630 to
fa6aba5
Compare
Signed-off-by: tariq-hasan <[email protected]>
fa6aba5 to
31cec01
Compare
andreyvelich
left a comment
There was a problem hiding this comment.
/lgtm
/approve
/hold for final approval from @vara-bonthu and @nabuskey
cc @Shekharrajak
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: andreyvelich The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/hold cancel |
|
/cherry-pick release-2.5 |
|
@andreyvelich: new pull request created: #2877 DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Purpose of this PR
This PR introduces admission webhook validation for the SparkConnect CRD, aligning it with the existing validation patterns used for SparkApplication.
Change Category
Rationale
The Spark Operator currently includes webhook validation for SparkApplication, but similar validation was not implemented for SparkConnect. This creates inconsistency and requires SDK-side validation that is better suited for controller-side enforcement.
This change:
Validation rules implemented:
Helm chart has been updated and
make manifestshas been run to regenerate webhook configs.Checklist
Additional Notes
Closes #2848.