Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ private[spark] object Constants {
val UI_PORT_NAME = "spark-ui"

// Environment Variables
val ENV_DRIVER_POD_IP = "SPARK_DRIVER_POD_IP"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it different to DRIVER_HOST_ADDRESS? I saw K8s uses DRIVER_HOST_ADDRESS to derive driver url for env var ENV_DRIVER_URL.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for review, @viirya .

In K8s, DRIVER_HOST_ADDRESS is protected by DriverServiceFeatureStep here.

require(kubernetesConf.getOption(DRIVER_HOST_KEY).isEmpty,
s"$DRIVER_HOST_KEY is not supported in Kubernetes mode, as the driver's hostname will be " +
"managed via a Kubernetes service.")

It's because we inject like this systematically.

val driverHostname = s"$resolvedServiceName.${kubernetesConf.namespace}.svc"
Map(DRIVER_HOST_KEY -> driverHostname,

However, when DNS doesn't work, we need IP which is unknown from the executor pods so far.

val ENV_DRIVER_URL = "SPARK_DRIVER_URL"
val ENV_EXECUTOR_CORES = "SPARK_EXECUTOR_CORES"
val ENV_EXECUTOR_MEMORY = "SPARK_EXECUTOR_MEMORY"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ case "$1" in
CMD=(
"$SPARK_HOME/bin/spark-submit"
--conf "spark.driver.bindAddress=$SPARK_DRIVER_BIND_ADDRESS"
--conf "spark.executorEnv.SPARK_DRIVER_POD_IP=$SPARK_DRIVER_BIND_ADDRESS"
--deploy-mode client
"$@"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,15 @@ private[spark] trait BasicTestsSuite { k8sSuite: KubernetesSuite =>
runSparkRemoteCheckAndVerifyCompletion(appArgs = Array(REMOTE_PAGE_RANK_FILE_NAME))
}
}

test("SPARK-42769: All executor pods have SPARK_DRIVER_POD_IP env variable", k8sTestTag) {
runSparkPiAndVerifyCompletion(
executorPodChecker = (executorPod: Pod) => {
doBasicExecutorPodCheck(executorPod)
executorPod.getSpec.getContainers.get(0).getEnv.asScala
.exists(envVar => envVar.getName == "SPARK_DRIVER_POD_IP")
})
}
}

private[spark] object BasicTestsSuite extends SparkFunSuite {
Expand Down