srowen commented on a change in pull request #23546: [SPARK-23153][K8s] Support
client dependencies with a Hadoop Compatible File System
URL: https://github.com/apache/spark/pull/23546#discussion_r276351148
##########
File path:
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/KubernetesUtils.scala
##########
@@ -209,4 +215,70 @@ private[spark] object KubernetesUtils extends Logging {
Hex.encodeHexString(random) + time
}
+ /**
+ * Upload files and modify their uris
+ */
+ def uploadAndTransformFileUris(fileUris: Iterable[String], conf:
Option[SparkConf] = None)
+ : Iterable[String] = {
+ fileUris.map { uri =>
+ uploadFileUri(uri, conf)
+ }
+ }
+
+ private def isLocalDependency(uri: URI): Boolean = {
+ Option(uri.getScheme).getOrElse("file") == "file"
+ }
+
+ def renameMainAppResource(resource: String, conf: SparkConf): String = {
+ val resolvedUri = Utils.resolveURI(resource)
+ if (resource != SparkLauncher.NO_RESOURCE &&
isLocalDependency(resolvedUri)) {
+ SparkLauncher.NO_RESOURCE
+ } else {
+ resource
+ }
+ }
+
+ def uploadFileUri(uri: String, conf: Option[SparkConf] = None): String = {
+ conf match {
+ case Some(sConf) =>
+ if (sConf.get(KUBERNETES_FILE_UPLOAD_PATH).isDefined) {
+ val fileUri = Utils.resolveURI(uri)
+ try {
+ val hadoopConf = SparkHadoopUtil.get.newConfiguration(sConf)
+ val uploadPath = sConf.get(KUBERNETES_FILE_UPLOAD_PATH).get
+ val fs = getHadoopFileSystem(Utils.resolveURI(uploadPath),
hadoopConf)
+ val targetUri = s"${uploadPath}/${fileUri.getPath.split("/").last}"
+ log.info(s"Uploading file: ${fileUri.getPath} to dest:
$targetUri...")
+ uploadFileToHadoopCompatibleFS(new Path(fileUri.getPath), new
Path(targetUri), fs)
+ targetUri
+ } catch {
+ case e: Exception =>
+ throw new SparkException(s"Uploading file ${fileUri.getPath}
failed...", e)
+ }
+ }
+ else
Review comment:
Put braces and else together
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]