-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-33748][K8S] Respect environment variables and configurations for Python executables #30735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,7 +31,6 @@ import scala.collection.JavaConverters._ | |
| import scala.collection.mutable.ArrayBuffer | ||
| import scala.util.{Properties, Try} | ||
|
|
||
| import org.apache.commons.io.FilenameUtils | ||
| import org.apache.commons.lang3.StringUtils | ||
| import org.apache.hadoop.conf.{Configuration => HadoopConfiguration} | ||
| import org.apache.hadoop.fs.{FileSystem, Path} | ||
|
|
@@ -387,20 +386,40 @@ private[spark] class SparkSubmit extends Logging { | |
| // Replace with the downloaded local jar path to avoid propagating hadoop compatible uris. | ||
| // Executors will get the jars from the Spark file server. | ||
| // Explicitly download the related files here | ||
| args.jars = renameResourcesToLocalFS(args.jars, localJars) | ||
| args.jars = localJars | ||
| val filesLocalFiles = Option(args.files).map { | ||
| downloadFileList(_, targetDir, sparkConf, hadoopConf, secMgr) | ||
| }.orNull | ||
| val archiveLocalFiles = Option(args.archives).map { uri => | ||
| val resolvedUri = Utils.resolveURI(uri) | ||
| val downloadedUri = downloadFileList( | ||
| UriBuilder.fromUri(resolvedUri).fragment(null).build().toString, | ||
| val archiveLocalFiles = Option(args.archives).map { uris => | ||
| val resolvedUris = Utils.stringToSeq(uris).map(Utils.resolveURI) | ||
| val localArchives = downloadFileList( | ||
| resolvedUris.map( | ||
| UriBuilder.fromUri(_).fragment(null).build().toString).mkString(","), | ||
| targetDir, sparkConf, hadoopConf, secMgr) | ||
| UriBuilder.fromUri(downloadedUri).fragment(resolvedUri.getFragment).build().toString | ||
|
|
||
| // SPARK-33748: this mimics the behaviour of Yarn cluster mode. If the driver is running | ||
| // in cluster mode, the archives should be available in the driver's current working | ||
| // directory too. | ||
| Utils.stringToSeq(localArchives).map(Utils.resolveURI).zip(resolvedUris).map { | ||
| case (localArchive, resolvedUri) => | ||
| val source = new File(localArchive.getPath) | ||
| val dest = new File( | ||
| ".", | ||
| if (resolvedUri.getFragment != null) resolvedUri.getFragment else source.getName) | ||
| logInfo( | ||
| s"Unpacking an archive $resolvedUri " + | ||
| s"from ${source.getAbsolutePath} to ${dest.getAbsolutePath}") | ||
| Utils.deleteRecursively(dest) | ||
| Utils.unpack(source, dest) | ||
|
|
||
| // Keep the URIs of local files with the given fragments. | ||
| UriBuilder.fromUri( | ||
| localArchive).fragment(resolvedUri.getFragment).build().toString | ||
| }.mkString(",") | ||
| }.orNull | ||
| args.files = renameResourcesToLocalFS(args.files, filesLocalFiles) | ||
| args.archives = renameResourcesToLocalFS(args.archives, archiveLocalFiles) | ||
| args.pyFiles = renameResourcesToLocalFS(args.pyFiles, localPyFiles) | ||
| args.files = filesLocalFiles | ||
| args.archives = archiveLocalFiles | ||
| args.pyFiles = localPyFiles | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -836,21 +855,6 @@ private[spark] class SparkSubmit extends Logging { | |
| (childArgs.toSeq, childClasspath.toSeq, sparkConf, childMainClass) | ||
| } | ||
|
|
||
| private def renameResourcesToLocalFS(resources: String, localResources: String): String = { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I read the codes multiple times for sure, and I think this code does a duplicated job.
|
||
| if (resources != null && localResources != null) { | ||
| val localResourcesSeq = Utils.stringToSeq(localResources) | ||
| Utils.stringToSeq(resources).map { resource => | ||
| val filenameRemote = FilenameUtils.getName(new URI(resource).getPath) | ||
| localResourcesSeq.find { localUri => | ||
| val filenameLocal = FilenameUtils.getName(new URI(localUri).getPath) | ||
| filenameRemote == filenameLocal | ||
| }.getOrElse(resource) | ||
| }.mkString(",") | ||
| } else { | ||
| resources | ||
| } | ||
| } | ||
|
|
||
| // [SPARK-20328]. HadoopRDD calls into a Hadoop library that fetches delegation tokens with | ||
| // renewer set to the YARN ResourceManager. Since YARN isn't configured in Mesos or Kubernetes | ||
| // mode, we must trick it into thinking we're YARN. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,11 +44,11 @@ if [ -n "$SPARK_EXTRA_CLASSPATH" ]; then | |
| SPARK_CLASSPATH="$SPARK_CLASSPATH:$SPARK_EXTRA_CLASSPATH" | ||
| fi | ||
|
|
||
| if [ "$PYSPARK_MAJOR_PYTHON_VERSION" == "3" ]; then | ||
| pyv3="$(python3 -V 2>&1)" | ||
| export PYTHON_VERSION="${pyv3:7}" | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| export PYSPARK_PYTHON="python3" | ||
| export PYSPARK_DRIVER_PYTHON="python3" | ||
| if ! [ -z ${PYSPARK_PYTHON+x} ]; then | ||
| export PYSPARK_PYTHON | ||
| fi | ||
| if ! [ -z ${PYSPARK_DRIVER_PYTHON+x} ]; then | ||
| export PYSPARK_DRIVER_PYTHON | ||
| fi | ||
|
|
||
| # If HADOOP_HOME is set and SPARK_DIST_CLASSPATH is not set, set it here so Hadoop jars are available to the executor. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.