← Back to Pull requests

feat: add per-application driver PodDisruptionBudget (#2949) #2954

Closed
unknown closed this pull request without merging on Jun 30, 2026 20:28 UTC
View on GitHub
unknown unknown commented on May 22, 2026 05:05 UTC
Author

Purpose of this PR

Adds an opt-in per-SparkApplication driver PodDisruptionBudget (PDB) so
operators can prevent voluntary disruption (node drains, autoscaler
evictions) of long-running drivers without resorting to cluster-wide
policy.

The feature is gated on two switches that both default to off, so the
change is a no-op for installations that do not opt in:

1. A controller-level flag, --enable-driver-pdb (chart value
controller.driverPodDisruptionBudget.enable), gives cluster operators
a single permission point.
2. A per-application field, spec.driverPodDisruptionBudget (bool),
lets app authors opt in once the operator gate is open.

When both gates are true, the controller maintains a policy/v1
PodDisruptionBudget with minAvailable: 1 and a matchLabels selector
that targets the driver pod by name. The PDB is owner-referenced to the
SparkApplication so it is GC'd at app deletion, and the reconcile loop
also cleans it up when the app reaches a terminal state or when the spec
is flipped back off.

PDB existence is converged on every non-terminal reconcile (Submitted and
Running state handlers), so:

  • Transient API errors during PDB create are retried via standard

  • controller-runtime backoff.
  • An operator restart with --enable-driver-pdb turned on retroactively

  • creates PDBs for already-running apps that opted in.
  • Flipping spec.driverPodDisruptionBudget from false to true (or true

  • to false) on a running app takes effect on the next reconcile cycle.

    Proposed changes:

  • API (api/v1beta2): add SparkApplicationSpec.DriverPodDisruptionBudget bool,

  • regenerate CRDs, deepcopy, OpenAPI, Python API, and chart CRDs.
  • Controller (internal/controller/sparkapplication): new driver_pdb.go

  • with idempotent ensureDriverPDB / createDriverPDB / deleteDriverPDB
    helpers; ensureDriverPDB wired into the Submitted and Running reconcile
    branches; PDB cleanup in cleanUpOnTermination.
  • Controller flag: --enable-driver-pdb (default false), plumbed through

  • cmd/operator/controller into Reconciler.Options.EnableDriverPDB.
  • RBAC: add policy/poddisruptionbudgets create/get/list/watch/update/patch/delete

  • to the controller role (Helm and Kustomize, in sync).
  • Helm chart: controller.driverPodDisruptionBudget.enable value, gated

  • RBAC rule, and helper template that emits the --enable-driver-pdb
    flag when set. Helm-unittest specs cover the on/off matrix.
  • Tests: 13 envtest specs in driver_pdb_test.go covering both gates,

  • spec-flip lifecycle, terminal-state cleanup, OwnerReferences GC, and
    reconcile-loop convergence after operator restart or spec flip; one
    Ginkgo e2e spec in test/e2e/pdb_test.go exercising the happy path
    on Kind.
  • Tooling: two Makefile fixes that the new e2e suite depends on -

  • make deploy loads the Spark runtime image into Kind alongside the
    operator image, and make e2e-test creates the Kind cluster on demand
    instead of assuming one exists.

    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

    A missing-driver event (node drain, autoscaler eviction, kubelet upgrade)
    restarts the entire Spark application from scratch. For long-running
    drivers this is an expensive failure mode that PDBs were designed to
    prevent, but cluster-wide PDB policy is too blunt - most users want PDBs
    only for opt-in drivers, not for every Spark driver in the cluster.

    The two-gate design (operator flag plus per-app field) keeps the cluster
    operator in control of whether the feature exists at all, while letting
    individual app authors opt their long-running pipelines in. Defaulting
    both gates to off avoids any behavior change for installations that do
    not opt in.

    Reconcile-loop convergence (rather than a one-shot create on submit)
    keeps PDB state correct across operator restarts, transient API failures,
    and spec edits - a missing PDB silently defeats the entire feature, so
    the controller errs on the side of repeatedly ensuring it exists.

    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

  • All generated artifacts (CRDs in config/crd/bases and

  • charts/spark-operator-chart/crds, deepcopy, OpenAPI, Python API,
    api-docs.md) are committed. make detect-crds-drift,
    make verify-codegen, make manifests, make helm-unittest,
    make kustomize-lint, make go-lint, and make unit-test all pass.
  • The feature is split across five commits: API + codegen, operator

  • code, tests, and two Makefile chores that the e2e suite depends on.
  • The e2e spec was verified manually on Kind with DEPLOY_METHOD=helm.
  • ---

    Co-authored with Claude Code.

    Diff: 633 lines (+474 / -159) across 7 files Reviewer: vjanelle Review duration: 57082m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.50) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 633 lines diff across 7 files
    0.50
    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%
    56%
    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.386
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #2954"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% 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: 50.4% (MEDIUM) · Higher = larger blast radius
    50.4%
    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: 56.8% · Lower = rushed or shallow review
    56.8%
    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: 21.8% · Safe to merge
    21.8%