← Back to Pull requests

feat(controller): allow Spark 4.2 NetworkPolicy creation #3240

Closed
unknown closed this pull request without merging on Oct 15, 2026 23:46 UTC
View on GitHub
unknown unknown commented on Oct 14, 2026 14:37 UTC
Author

Purpose of this PR

Adds the controller RBAC required for Spark 4.2's default Kubernetes NetworkPolicy behavior.

This is a prerequisite for the Spark 4.2 migration discussed in #3218.

Proposed changes:

  • Allow the controller to create and patch networkpolicies.networking.k8s.io.

  • Add the corresponding Kubebuilder RBAC marker and regenerate the Kustomize RBAC manifest.

  • Add the equivalent Helm RBAC rule.

  • Add a Helm unit test covering the required NetworkPolicy permissions.
  • 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

    Spark 4.2 configures a Kubernetes NetworkPolicy by default so that executor pods only accept ingress traffic from the driver and peer executors in the same job.

    This behavior is documented in the Apache Spark 4.2 Core migration guide.

    I reproduced this using an Apache Spark 4.2 controller runtime.

    With only patch permission, submission failed because Kubernetes also required create for the server-side apply operation:

    cannot create resource "networkpolicies" in API group "networking.k8s.io"
    

    After granting only create and patch:

  • the NetworkPolicy was created successfully

  • the Spark driver and executor ran

  • SparkPi completed with exit code 0

  • the SparkApplication reached COMPLETED
  • No broader NetworkPolicy permissions are added because they were not required by the tested Spark 4.2 submission path.

    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

    Local validation completed successfully:

  • make helm-unittest - 246/246 tests passed

  • make kustomize-lint - passed

  • make drift-check - passed

  • make go-fmt - passed

  • make go-vet - passed

  • make go-lint - 0 issues

  • make unit-test - passed

  • go mod tidy - no changes

  • go -C test/e2e mod tidy - no changes

  • Spark 4.2 functional submission with the NetworkPolicy feature enabled - passed
  • No documentation changes are included in this prerequisite RBAC PR. User-facing Spark 4.2 migration and compatibility documentation can be handled together with the follow-up Spark 4.2 runtime update tracked in #3218.

    Part of #3218.

    Diff: 336 lines (+252 / -84) across 4 files Reviewer: vjanelle Review duration: 1989m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 336 lines diff across 4 files
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    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.348
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #3240"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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.2% (MEDIUM) · Higher = larger blast radius
    42.2%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 16.7% · Safe to merge
    16.7%