You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/01/09 17:17:08 UTC

[GitHub] tgravescs commented on a change in pull request #23260: [SPARK-26311][YARN] New feature: custom log URL for stdout/stderr

tgravescs commented on a change in pull request #23260: [SPARK-26311][YARN] New feature: custom log URL for stdout/stderr
URL: https://github.com/apache/spark/pull/23260#discussion_r246467597
 
 

 ##########
 File path: resource-managers/yarn/src/main/scala/org/apache/spark/deploy/yarn/ExecutorRunnable.scala
 ##########
 @@ -246,13 +253,57 @@ private[yarn] class ExecutorRunnable(
       sys.env.get("SPARK_USER").foreach { user =>
         val containerId = ConverterUtils.toString(c.getId)
         val address = c.getNodeHttpAddress
-        val baseUrl = s"$httpScheme$address/node/containerlogs/$containerId/$user"
 
-        env("SPARK_LOG_URL_STDERR") = s"$baseUrl/stderr?start=-4096"
-        env("SPARK_LOG_URL_STDOUT") = s"$baseUrl/stdout?start=-4096"
+        val customLogUrl = sparkConf.get(config.CUSTOM_LOG_URL)
+
+        val envNameToFileNameMap = Map("SPARK_LOG_URL_STDERR" -> "stderr",
+          "SPARK_LOG_URL_STDOUT" -> "stdout")
+        val logUrls = ExecutorRunnable.buildLogUrls(customLogUrl, httpScheme, address,
+          clusterId, containerId, user, envNameToFileNameMap)
+        logUrls.foreach { case (envName, url) =>
+          env(envName) = url
+        }
       }
     }
 
     env
   }
 }
+
+private[yarn] object ExecutorRunnable {
+  def buildLogUrls(
+      logUrlPattern: String,
+      httpScheme: String,
+      nodeHttpAddress: String,
+      clusterId: Option[String],
+      containerId: String,
+      user: String,
+      envNameToFileNameMap: Map[String, String]): Map[String, String] = {
+    val optionalPathVariable: Map[String, Option[String]] = Map("{{ClusterId}}" -> clusterId)
+    val pathVariables: Map[String, String] = Map("{{HttpScheme}}" -> httpScheme,
 
 Review comment:
   I must be missing something why are some optional and others not, if a user want to do a custom url couldn't they not have containerid or user for instance?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org