[SPARK-58748][CORE][K8S] Preserve advertised driver host for wildcard bind addresses - #57977
Open
sunchao wants to merge 1 commit into
Open
Conversation
sunchao
marked this pull request as ready for review
August 13, 2026 03:01
Member
Author
sarutak
reviewed
Aug 13, 2026
| if (SparkMasterRegex.isK8s(master) && | ||
| _conf.getBoolean("spark.kubernetes.executor.useDriverPodIP", true)) { | ||
| _conf.getBoolean("spark.kubernetes.executor.useDriverPodIP", true) && | ||
| !Utils.isAnyLocalAddress(_conf.get(DRIVER_BIND_ADDRESS))) { |
Member
There was a problem hiding this comment.
nit: When the wildcard fallback is taken, could we add a log line so users know why DRIVER_BIND_ADDRESS wasn't used as the advertised address? e.g.:
logInfo(log"spark.kubernetes.executor.useDriverPodIP is true but bind address " +
log"${MDC(LogKeys.BIND_ADDRESS, _conf.get(DRIVER_BIND_ADDRESS))} is a wildcard; " +
log"preserving advertised driver host ${MDC(LogKeys.HOST, _conf.get(DRIVER_HOST_ADDRESS))}")
This would help users debug cases where they set useDriverPodIP=true but the bind address is intentionally 0.0.0.0 or ::.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Teach Spark to distinguish the address a Kubernetes driver listens on from the address executors should connect to when direct driver-Pod-IP mode is enabled.
Normally, using the driver's bind address as its advertised address works: a Kubernetes-managed driver binds directly to its Pod IP, and executors can connect to that IP without going through a driver Service. That assumption breaks when a driver intentionally binds to every network interface. An address such as
0.0.0.0or::means "listen everywhere," but it does not identify a reachable peer.This change makes the choice depend on the address itself. A concrete bind address continues to use the existing direct-Pod-IP path. A wildcard bind address instead preserves the separately configured, routable
spark.driver.host. Both driver initialization and executor endpoint construction apply the same rule, so the address advertised by the driver and the address given to executors remain consistent. Wildcard recognition supports IPv4 and IPv6 without performing DNS lookups, and existing IPv6 normalization is preserved.Why are the changes needed?
SPARK-58748
Spark deliberately separates two network settings:
This is a legitimate and common configuration for Kubernetes client-mode applications and Spark Connect servers: the process listens on all local interfaces, while executors are told to connect to the driver's actual Pod IP or a routable Service hostname.
The problem appears when direct driver-Pod-IP mode is enabled:
Spark currently assumes the driver's bind address is always its Pod IP. Consequently,
SparkContextreplaces the configured advertised host with0.0.0.0, and Kubernetes executor creation independently uses that same wildcard to construct the scheduler endpoint:The driver starts successfully because binding to
0.0.0.0is valid. The failure only becomes visible when executors try to register, leaving the application running but unable to execute tasks. Fixing only one side is insufficient: the driver and executor each make their own address-selection decision, and both must preserve the advertised host.The same distinction applies to IPv6. For example, a driver may listen on
::while advertising a concrete address such as[2001:db8::42]; executors must receive the concrete address, never the IPv6 wildcard. Compressed, bracketed, and expanded IPv6 wildcard forms are handled consistently.Spark 4.1 and 4.2 are affected when
spark.kubernetes.executor.useDriverPodIPis explicitly enabled. Spark 4.3 and current master enable it by default, so previously valid wildcard-bind configurations can fail without any application-level configuration change.Does this PR introduce any user-facing change?
Yes. Kubernetes applications that bind their driver to all interfaces now retain the reachable address configured in
spark.driver.host, allowing their executors to register and run. This restores the existing documented distinction between the driver's listening address and its advertised address.Applications that bind directly to a concrete Pod IP continue using direct-IP routing, including existing IPv6 normalization. Applications with direct driver-Pod-IP mode disabled, and applications outside Kubernetes, retain their existing behavior. No configuration defaults or public APIs change.
How was this patch tested?
All 41 tests passed: one targeted
SparkContextSuiteregression, one targetedUtilsSuiteregression, and all 39BasicExecutorFeatureStepSuitetests. Together, they cover default-enabled driver initialization, explicitly enabled and disabled executor configuration, IPv4 and IPv6 wildcard addresses, concrete IPv4 and IPv6 addresses, executor driver URLs, and existing IPv6 normalization. All four Scala style checks also passed.Was this patch authored or co-authored using generative AI tooling?
Generated-by: OpenAI Codex