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 @@ -30,12 +30,14 @@ set -e
# If there is no passwd entry for the container UID, attempt to create one
if [ -z "$uidentry" ] ; then
if [ -w /etc/passwd ] ; then
echo "$myuid:x:$myuid:$mygid:${SPARK_USER_NAME:-anonymous uid}:$SPARK_HOME:/bin/false" >> /etc/passwd
echo "${SPARK_USER_NAME:-$myuid}:x:$myuid:$mygid:${SPARK_USER_NAME:-anonymous uid}:$SPARK_HOME:/bin/false" >> /etc/passwd
else
echo "Container ENTRYPOINT failed to add passwd entry for anonymous UID"
fi
fi

echo "login user is `id -un`"

if [ -z "$JAVA_HOME" ]; then
JAVA_HOME=$(java -XshowSettings:properties -version 2>&1 > /dev/null | grep 'java.home' | awk '{print $3}')
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import org.scalatest.matchers.should.Matchers._
import org.scalatest.time.{Seconds, Span}

import org.apache.spark.{SparkFunSuite, TestUtils}
import org.apache.spark.deploy.k8s.integrationtest.KubernetesSuite.SPARK_PI_MAIN_CLASS
import org.apache.spark.deploy.k8s.integrationtest.KubernetesSuite.{usernameTestTag, SPARK_PI_MAIN_CLASS}
import org.apache.spark.launcher.SparkLauncher

private[spark] trait BasicTestsSuite { k8sSuite: KubernetesSuite =>
Expand Down Expand Up @@ -168,6 +168,22 @@ private[spark] trait BasicTestsSuite { k8sSuite: KubernetesSuite =>
.exists(envVar => envVar.getName == "SPARK_DRIVER_POD_IP")
})
}

test("SPARK-43171: Support custom Unix username in Pod", k8sTestTag, usernameTestTag) {
sparkAppConf
.set("spark.kubernetes.driverEnv.SPARK_USER_NAME", "spark-kube")
.set("spark.executorEnv.SPARK_USER_NAME", "spark-kube")
runSparkApplicationAndVerifyCompletion(
containerLocalSparkDistroExamplesJar,
SPARK_PI_MAIN_CLASS,
Seq("login user is spark-kube", "Pi is roughly 3"),
Seq("login user is spark-kube"),
appArgs = Array.empty,
doBasicDriverPodCheck,
doBasicExecutorPodCheck,
isJVM = true
)
}
}

private[spark] object BasicTestsSuite extends SparkFunSuite {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ private[spark] object KubernetesSuite {
val decomTestTag = Tag("decom")
val rTestTag = Tag("r")
val MinikubeTag = Tag("minikube")
val usernameTestTag = Tag("username")
Copy link
Member Author

Choose a reason for hiding this comment

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

@Yikun A new tag is added, you can use it to exclude this test for apache/spark-docker GA

val SPARK_PI_MAIN_CLASS: String = "org.apache.spark.examples.SparkPi"
val SPARK_DFS_READ_WRITE_TEST = "org.apache.spark.examples.DFSReadWriteTest"
val SPARK_MINI_READ_WRITE_TEST = "org.apache.spark.examples.MiniReadWriteTest"
Expand Down