Skip to content

Commit b81a702

Browse files
liyichaoMarcelo Vanzin
authored andcommitted
[SPARK-20365][YARN] Remove local scheme when add path to ClassPath.
In Spark on YARN, when configuring "spark.yarn.jars" with local jars (jars started with "local" scheme), we will get inaccurate classpath for AM and containers. This is because we don't remove "local" scheme when concatenating classpath. It is OK to run because classpath is separated with ":" and java treat "local" as a separate jar. But we could improve it to remove the scheme. Updated `ClientSuite` to check "local" is not in the classpath. cc jerryshao Author: Li Yichao <[email protected]> Author: Li Yichao <[email protected]> Closes #18129 from liyichao/SPARK-20365. (cherry picked from commit 640afa4) Signed-off-by: Marcelo Vanzin <[email protected]>
1 parent 6a4e023 commit b81a702

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

resource-managers/yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,8 @@ private object Client extends Logging {
12751275
if (sparkConf.get(SPARK_ARCHIVE).isEmpty) {
12761276
sparkConf.get(SPARK_JARS).foreach { jars =>
12771277
jars.filter(isLocalUri).foreach { jar =>
1278-
addClasspathEntry(getClusterPath(sparkConf, jar), env)
1278+
val uri = new URI(jar)
1279+
addClasspathEntry(getClusterPath(sparkConf, uri.getPath()), env)
12791280
}
12801281
}
12811282
}

resource-managers/yarn/src/test/scala/org/apache/spark/deploy/yarn/ClientSuite.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ class ClientSuite extends SparkFunSuite with Matchers with BeforeAndAfterAll
122122
cp should not contain (uri.getPath())
123123
}
124124
})
125+
cp should not contain ("local")
125126
cp should contain(PWD)
126127
cp should contain (s"$PWD${Path.SEPARATOR}${LOCALIZED_CONF_DIR}")
127128
cp should not contain (APP_JAR)

0 commit comments

Comments
 (0)