otterc commented on a change in pull request #30096:
URL: https://github.com/apache/spark/pull/30096#discussion_r516858215



##########
File path: 
resource-managers/yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala
##########
@@ -1172,6 +1181,31 @@ private[spark] class Client(
     }.mkString("")
   }
 
+  private def getDriverLogsLink(appId: String): Option[(String, String)] = {
+    val baseRmUrl = WebAppUtils.getRMWebAppURLWithScheme(hadoopConf)
+    val response = ClientBuilder.newClient()
+      .target(baseRmUrl)
+      
.path("ws").path("v1").path("cluster").path("apps").path(appId).path("appattempts")
+      .request(MediaType.APPLICATION_JSON)
+      .get()
+    response.getStatusInfo.getFamily match {
+      case Family.SUCCESSFUL =>
+        val objectMapper = new ObjectMapper()
+        // If JSON response is malformed somewhere along the way, MissingNode 
will be returned,
+        // which allows for safe continuation of chaining. The `elements()` 
call will be empty,
+        // and None will get returned.
+        objectMapper.readTree(response.readEntity(classOf[String]))
+            .path("appAttempts").path("appAttempt")
+            .elements().asScala.toList.takeRight(1).headOption
+            .map(_.path("logsLink").asText())
+            .map(baseUrl => (s"$baseUrl/stdout?start=-4096", 
s"$baseUrl/stderr?start=-4096"))
+      case _ =>
+        logInfo(s"Unable to fetch app attempts info from $baseRmUrl, got "

Review comment:
       Should this be at Info level?

##########
File path: 
resource-managers/yarn/src/main/scala/org/apache/spark/deploy/yarn/Client.scala
##########
@@ -1172,6 +1181,31 @@ private[spark] class Client(
     }.mkString("")
   }
 
+  private def getDriverLogsLink(appId: String): Option[(String, String)] = {
+    val baseRmUrl = WebAppUtils.getRMWebAppURLWithScheme(hadoopConf)
+    val response = ClientBuilder.newClient()
+      .target(baseRmUrl)
+      
.path("ws").path("v1").path("cluster").path("apps").path(appId).path("appattempts")
+      .request(MediaType.APPLICATION_JSON)
+      .get()
+    response.getStatusInfo.getFamily match {
+      case Family.SUCCESSFUL =>
+        val objectMapper = new ObjectMapper()
+        // If JSON response is malformed somewhere along the way, MissingNode 
will be returned,
+        // which allows for safe continuation of chaining. The `elements()` 
call will be empty,
+        // and None will get returned.
+        objectMapper.readTree(response.readEntity(classOf[String]))
+            .path("appAttempts").path("appAttempt")

Review comment:
       Nit: indentation should be 2 spaces




----------------------------------------------------------------
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:
us...@infra.apache.org



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

Reply via email to