dongjoon-hyun commented on a change in pull request #30472:
URL: https://github.com/apache/spark/pull/30472#discussion_r535758501
##########
File path:
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/submit/KubernetesClientUtils.scala
##########
@@ -94,25 +120,41 @@ private[spark] object KubernetesClientUtils extends
Logging {
val confDir = Option(conf.getenv(ENV_SPARK_CONF_DIR)).orElse(
conf.getOption("spark.home").map(dir => s"$dir/conf"))
if (confDir.isDefined) {
- val confFiles = listConfFiles(confDir.get)
- logInfo(s"Spark configuration files loaded from $confDir :
${confFiles.mkString(",")}")
- confFiles.map { file =>
- val source = Source.fromFile(file)(Codec.UTF8)
- val mapping = (file.getName -> source.mkString)
- source.close()
- mapping
- }.toMap
+ val confFiles = listConfFiles(confDir.get,
conf.get(Config.CONFIG_MAP_MAXSIZE))
+ val filesSeq: Seq[Option[(String, String)]] = confFiles.map { file =>
+ try {
+ val source = Source.fromFile(file)(Codec.UTF8)
+ val mapping = Some(file.getName -> source.mkString)
+ source.close()
+ mapping
+ } catch {
+ case e: MalformedInputException =>
+ logWarning(s"skipped a non UTF-8 encoded file
${file.getAbsolutePath}.", e)
+ None
+ }
+ }
+ val truncatedMap = truncateToSize(filesSeq.flatten,
conf.get(Config.CONFIG_MAP_MAXSIZE))
+ logInfo(s"Spark configuration files loaded from $confDir :" +
+ s" ${truncatedMap.keys.mkString(",")}")
+ truncatedMap
} else {
Map.empty[String, String]
}
}
- private def listConfFiles(confDir: String): Seq[File] = {
- // We exclude all the template files and user provided spark conf or
properties.
- // As spark properties are resolved in a different step.
+ private def listConfFiles(confDir: String, maxSize: Long): Seq[File] = {
+ // At the moment configmaps does not support storing binary content.
+ // configMaps do not allow for size greater than 1.5 MiB(configurable).
+ // https://etcd.io/docs/v3.4.0/dev-guide/limit/
+ // We exclude all the template files and user provided spark conf or
properties,
+ // and binary files (e.g. jars and zip). Spark properties are resolved in
a different step.
+ def test(f: File): Boolean = (f.length() + f.getName.length > maxSize) ||
Review comment:
`test` looks a little too broad name.
##########
File path:
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/submit/KubernetesClientUtils.scala
##########
@@ -94,25 +120,41 @@ private[spark] object KubernetesClientUtils extends
Logging {
val confDir = Option(conf.getenv(ENV_SPARK_CONF_DIR)).orElse(
conf.getOption("spark.home").map(dir => s"$dir/conf"))
if (confDir.isDefined) {
- val confFiles = listConfFiles(confDir.get)
- logInfo(s"Spark configuration files loaded from $confDir :
${confFiles.mkString(",")}")
- confFiles.map { file =>
- val source = Source.fromFile(file)(Codec.UTF8)
- val mapping = (file.getName -> source.mkString)
- source.close()
- mapping
- }.toMap
+ val confFiles = listConfFiles(confDir.get,
conf.get(Config.CONFIG_MAP_MAXSIZE))
+ val filesSeq: Seq[Option[(String, String)]] = confFiles.map { file =>
+ try {
+ val source = Source.fromFile(file)(Codec.UTF8)
+ val mapping = Some(file.getName -> source.mkString)
+ source.close()
+ mapping
+ } catch {
+ case e: MalformedInputException =>
+ logWarning(s"skipped a non UTF-8 encoded file
${file.getAbsolutePath}.", e)
+ None
+ }
+ }
+ val truncatedMap = truncateToSize(filesSeq.flatten,
conf.get(Config.CONFIG_MAP_MAXSIZE))
+ logInfo(s"Spark configuration files loaded from $confDir :" +
+ s" ${truncatedMap.keys.mkString(",")}")
+ truncatedMap
} else {
Map.empty[String, String]
}
}
- private def listConfFiles(confDir: String): Seq[File] = {
- // We exclude all the template files and user provided spark conf or
properties.
- // As spark properties are resolved in a different step.
+ private def listConfFiles(confDir: String, maxSize: Long): Seq[File] = {
+ // At the moment configmaps does not support storing binary content.
+ // configMaps do not allow for size greater than 1.5 MiB(configurable).
+ // https://etcd.io/docs/v3.4.0/dev-guide/limit/
+ // We exclude all the template files and user provided spark conf or
properties,
+ // and binary files (e.g. jars and zip). Spark properties are resolved in
a different step.
+ def test(f: File): Boolean = (f.length() + f.getName.length > maxSize) ||
Review comment:
`test` looks like a little too broad name.
----------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]