[SPARK-59518][K8S] Fall back to the driver service account when the executor one is empty by anshulbaliga7 · Pull Request #58807 · apache/spark · GitHub
Skip to content

[SPARK-59518][K8S] Fall back to the driver service account when the executor one is empty - #58807

Open
anshulbaliga7 wants to merge 1 commit into
apache:masterfrom
anshulbaliga7:SPARK-59518-empty-executor-service-account
Open

anshulbaliga7 wants to merge 1 commit into
apache:masterfrom
anshulbaliga7:SPARK-59518-empty-executor-service-account

Conversation

@anshulbaliga7

@anshulbaliga7 anshulbaliga7 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

ExecutorKubernetesCredentialsFeatureStep now treats an explicitly empty
spark.kubernetes.authenticate.executor.serviceAccountName as unset. The optional config is filtered with .filter(_.nonEmpty) before the fallback runs, so an empty executor account falls back to the driver account, as documented. With no driver account configured either, the executor pod spec is left untouched instead of receiving "".

The config description in docs/running-on-kubernetes.md is updated to say "not set or is empty". The change is confined to the executor config read so it stays independent of #58343 (SPARK-58910), which reworks the pod-template check in the same step.

Why are the changes needed?

The executor service account config is createOptional, so setting it to an empty string yields Some(""). executorServiceAccount.orElse(driverServiceAccount) then never falls back, and buildPodWithServiceAccount writes an empty serviceAccount / serviceAccountName into the executor pod. That contradicts the documented behavior ("if this parameter is not setup, the fallback logic will use the driver's service account") and produces a pod that names no usable account. An empty value is easy to hit from templating or --conf key= in submission scripts.

Does this PR introduce any user-facing change?

Yes, a bug fix. Before, --conf spark.kubernetes.authenticate.executor.serviceAccountName= with a driver account configured wrote serviceAccountName: "" to executor pods. Now such executors use the driver's service account, matching the behavior when the config is absent. Non-empty
values behave exactly as before.

How was this patch tested?

Two new tests in ExecutorKubernetesCredentialsFeatureStepSuite:

  • empty executor account plus a driver account resolves to the driver account;
  • empty executor account with no driver account leaves serviceAccount / serviceAccountName
    null.
build/sbt -Pkubernetes "kubernetes/testOnly org.apache.spark.deploy.k8s.features.ExecutorKubernetesCredentialsFeatureStepSuite"

All 5 tests pass (3 existing, 2 new).

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Claude Fable 5.1)

@anshulbaliga7
anshulbaliga7 force-pushed the SPARK-59518-empty-executor-service-account branch from 936a169 to 968333d Compare September 15, 2026 06:50
@anshulbaliga7

Copy link
Copy Markdown
Contributor Author

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant