feat: env-configurable spark-submit binary name

Hardcoding 'spark-submit' as cmd[0] in build_spark_submit_command
breaks for hosts where:
  - both Spark 1.x and 2.x/3.x are installed and 'spark-submit' resolves
    to the wrong one (use 'spark2-submit' or 'spark3-submit' explicitly)
  - the user wants to launch via the PySpark entrypoint ('pyspark')
  - a custom wrapper script sits on PATH (e.g. a credentials-injecting
    'spark-submit-wrapper')

New env var SPARK_EXECUTOR_SPARK_SUBMIT_BIN. Default is 'spark-submit'
(preserves the current behavior for everyone). Override in .env /
docker-compose.yml to change.

common/config.py:
  - new Settings.spark_submit_bin field
  - env-var resolution in from_env() with default 'spark-submit'
  - included in reload() so tests work

spark_executor/core/spark_submit.py:
  - cmd[0] reads settings.spark_submit_bin (was hardcoded 'spark-submit')

.env.example: new section with the override and example values.
docker-compose.yml: forwards the var with the standard 'spark-submit'
default.

Tests: 2 new (settings.spark_submit_bin='spark2-submit', ='pyspark')
plus existing tests updated to use the settings-restore fixture so
mutations don't leak between tests.

165/163 still pass.
This commit is contained in:
Claude
2026-06-25 16:46:59 +08:00
parent cb909f7fea
commit 1c9e4a321d
5 changed files with 87 additions and 2 deletions
+10
View File
@@ -49,6 +49,16 @@ YARN_RESOURCE_MANAGER_URL=
# SPARK_EXECUTOR_LOG_LEVEL=DEBUG
# SPARK_EXECUTOR_LOG_LEVEL=INFO
# --- Spark CLI binary name ---
# The program name used to invoke the Spark client. Defaults to
# 'spark-submit' (the standard Spark 2.x / 3.x / 4.x CLI). Override to
# 'spark2-submit' on hosts with mixed-version Spark installs, or to
# a wrapper script path (e.g. /usr/local/bin/spark-submit-wrapper).
# The binary is resolved against $PATH (set by docker-entrypoint.sh).
#
# SPARK_EXECUTOR_SPARK_SUBMIT_BIN=spark-submit
# SPARK_EXECUTOR_SPARK_SUBMIT_BIN=spark2-submit
# --- Optional: JVM flags forwarded to spark-submit ---
# Useful for proxies, custom truststores, or driver memory caps.
# SPARK_SUBMIT_OPTS=-Dhttps.proxyHost=proxy.corp -Dhttps.proxyPort=3128