Skip to content

[KYUUBI #7749][K8S] Validate spark.submit.deployMode for Kubernetes batch submission - #7750

Open
HwangDongJun wants to merge 2 commits into
apache:masterfrom
HwangDongJun:fix-k8s-batch-deploy-mode-validation
Open

HwangDongJun wants to merge 2 commits into
apache:masterfrom
HwangDongJun:fix-k8s-batch-deploy-mode-validation

Conversation

@HwangDongJun

@HwangDongJun HwangDongJun commented Sep 16, 2026 •

Copy link
Copy Markdown

Why are the changes needed?

When submitting a Spark batch job via the Batch REST API with spark.master=k8s://..., Kyuubi does not validate that spark.submit.deployMode is cluster. If deployMode is client (Spark's own default when unset), Kyuubi still proceeds to submit the job, and Spark runs the driver as a subprocess of the Kyuubi server itself instead of creating a separate Kubernetes driver pod. This breaks batch status tracking (which relies on finding a driver pod tagged with kyuubi-unique-tag) and produces confusing errors that give no indication of the actual root cause.

Root cause is two compounding issues:

  1. BatchJobSubmission never calls builder.validateConf() at all, so the existing Validator.validateConf() safety check (currently validating spark.kubernetes.executor.podNamePrefix length) has never been exercised for any batch job.
  2. Even when invoked, Validator has no check for the spark.master / deployMode combination.

This adds an override of validateConf() in SparkBatchProcessBuilder that fails fast with a clear error when spark.master is k8s:// and deployMode is not cluster, and wires up the missing validateConf() call in BatchJobSubmission.

K8s client mode is already unsupported for batches (the JPS fallback was removed from KubernetesApplicationOperation in #4469, see the TODO in isSupported). This rejects it at submission instead of failing later. Wiring validateConf() into BatchJobSubmission also enables the existing podNamePrefix check for batches, which only EngineRef called before.

See #7749 for full reproduction details.

How was this patch tested?

Added 4 new unit tests to SparkBatchProcessBuilderSuite:

  • reject k8s batch submission when deployMode is client
  • reject k8s batch submission when deployMode is unset
  • allow k8s batch submission when deployMode is cluster
  • do not reject non-k8s masters (local[*], yarn client) regardless of deployMode

Added a case to BatchesResourceSuite that opens a batch with a k8s:// master and no spark.submit.deployMode, and checks that the submission is rejected before spark-submit is launched. It fails if the validateConf() call in BatchJobSubmission is removed.

Ran the full kyuubi-server test suite locally (mvn test -pl kyuubi-server -am -P spark-3.5) — all 6 tests in SparkBatchProcessBuilderSuite pass, including the 2 pre-existing tests (no regression).

Also verified via a fork-internal CI dry-run (base/head both in my own fork) that the full CI matrix passes with this change: all 33 checks green, including Kyuubi and Spark Test across Java 17/21/25 × Spark 3.5/4.0/4.1/4.2, Kyuubi Server On Kubernetes Integration Test, Spark Engine On Kubernetes Integration Test, and Style check.

Was this patch assisted by generative AI tooling?

Assisted-by: claude-sonnet-5

…etes batch submission

### Why are the changes needed?

When submitting a Spark batch job via the Batch REST API with spark.master=k8s://...,
Kyuubi does not validate that spark.submit.deployMode is cluster. If deployMode is
client (Spark's own default when unset), Kyuubi still proceeds to submit the job, and
Spark runs the driver as a subprocess of the Kyuubi server itself instead of creating a
separate Kubernetes driver pod. This breaks batch status tracking (which relies on
finding a driver pod tagged with kyuubi-unique-tag) and produces confusing errors that
give no indication of the actual root cause.

Root cause is two compounding issues:
1. BatchJobSubmission never calls builder.validateConf() at all, so the existing
   Validator.validateConf() safety check (currently validating
   spark.kubernetes.executor.podNamePrefix length) has never been exercised for any
   batch job.
2. Even when invoked, Validator has no check for the spark.master / deployMode
   combination.

This adds an override of validateConf() in SparkBatchProcessBuilder that fails fast
with a clear error when spark.master is k8s:// and deployMode is not cluster, and wires
up the missing validateConf() call in BatchJobSubmission.

See apache#7749 for full reproduction details.

### How was this patch tested?

Added 4 new unit tests to SparkBatchProcessBuilderSuite:
- reject k8s batch submission when deployMode is client
- reject k8s batch submission when deployMode is unset
- allow k8s batch submission when deployMode is cluster
- do not reject non-k8s masters (local[*], yarn client) regardless of deployMode

Ran the full kyuubi-server test suite locally (mvn test -pl kyuubi-server -am
-P spark-3.5) — all 6 tests in SparkBatchProcessBuilderSuite pass, including the 2
pre-existing tests (no regression).

### Was this patch assisted by generative AI tooling?

Assisted-by: OpenCode (claude-sonnet-5)
… mode in batch submission

### Why are the changes needed?

The existing `SparkBatchProcessBuilderSuite` cases call `validateConf()` directly, so they
still pass when the `builder.validateConf()` call in `BatchJobSubmission` is removed.

### How was this patch tested?

Added a test to `BatchesResourceSuite` that opens a batch with a `k8s://` master and no
`spark.submit.deployMode`, and checks that the operation fails before `spark-submit` is
launched, with the expected error message.

Ran `BatchesV1ResourceSuite` locally. All 15 tests pass, and the new test fails when the
`builder.validateConf()` call in `BatchJobSubmission` is removed:

```
build/mvn test -pl kyuubi-server -am -Pspark-3.5 -Dtest=none \
  -DwildcardSuites=org.apache.kyuubi.server.api.v1.BatchesV1ResourceSuite
```
@HwangDongJun

Copy link
Copy Markdown
Author

@pan3793 could you take a look when you have time? For K8s batch, spark.submit.deployMode defaults to Spark's client, and in that mode no driver pod exists for KubernetesApplicationOperation to find by kyuubi-unique-tag. This rejects that case at submission via SparkBatchProcessBuilder.validateConf() with an explicit message.

BatchJobSubmission did not call validateConf() before, so this also enables the existing podNamePrefix check for batches for the first time. The new BatchesResourceSuite case fails if that call is removed.

The workflows on the latest commit are waiting for maintainer approval. The same commit passes all checks in my fork's CI.

@HwangDongJun

Copy link
Copy Markdown
Author

@turboFei could you approve the workflows on this PR? The five workflows on the latest commit (d6ecc48) are in action_required and have not started, so there is no CI result on the apache side. The same commit passes all checks in my fork's CI.

@aajisaka aajisaka closed this Nov 29, 2026
@aajisaka aajisaka reopened this Nov 29, 2026
@aajisaka

Copy link
Copy Markdown
Member

I once closed and reopened this PR to approve the workflow.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants