[ https://issues.apache.org/jira/browse/SPARK-26311?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16718111#comment-16718111 ]
ASF GitHub Bot commented on SPARK-26311: ---------------------------------------- HeartSaVioR 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_r240817431 ########## File path: resource-managers/yarn/src/test/scala/org/apache/spark/deploy/yarn/YarnLogUrlSuite.scala ########## @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.spark.deploy.yarn + +import org.apache.spark.SparkFunSuite + +class YarnLogUrlSuite extends SparkFunSuite { + + private val testHttpScheme = "https://" + private val testNodeHttpAddress = "nodeManager:1234" + private val testContainerId = "testContainer" + private val testUser = "testUser" + private val testEnvNameToFileNameMap = Map("TEST_ENV_STDOUT" -> "stdout", + "TEST_ENV_STDERR" -> "stderr") + + test("Custom log URL - leverage all patterns, all values for patterns are available") { + val logUrlPattern = "{{HttpScheme}}{{NodeHttpAddress}}/logs/clusters/{{ClusterId}}" + + "/containers/{{ContainerId}}/users/{{User}}/files/{{FileName}}" + + val clusterId = Some("testCluster") + + val logUrls = ExecutorRunnable.buildLogUrls(logUrlPattern, testHttpScheme, testNodeHttpAddress, + clusterId, testContainerId, testUser, testEnvNameToFileNameMap) + + val expectedLogUrls = testEnvNameToFileNameMap.map { case (envName, fileName) => + envName -> (s"$testHttpScheme$testNodeHttpAddress/logs/clusters/${clusterId.get}" + + s"/containers/$testContainerId/users/$testUser/files/$fileName") + } + + assert(logUrls === expectedLogUrls) + } + + test("Custom log URL - optional pattern is not used in log URL") { + // here {{ClusterId}} is excluded in this pattern + val logUrlPattern = "{{HttpScheme}}{{NodeHttpAddress}}/logs/containers/{{ContainerId}}" + + "/users/{{User}}/files/{{FileName}}" + + // suppose the value of {{ClusterId}} pattern is not available + val clusterId = None + + // This should not throw an exception: the value for optional pattern is not available + // but we also don't use the pattern in log URL. + val logUrls = ExecutorRunnable.buildLogUrls(logUrlPattern, testHttpScheme, testNodeHttpAddress, + clusterId, testContainerId, testUser, testEnvNameToFileNameMap) + + val expectedLogUrls = testEnvNameToFileNameMap.map { case (envName, fileName) => + envName -> (s"$testHttpScheme$testNodeHttpAddress/logs/containers/$testContainerId" + + s"/users/$testUser/files/$fileName") + } + + assert(logUrls === expectedLogUrls) + } + + test("Custom log URL - optional pattern is used in log URL but the value " + + "is not present") { Review comment: Will address. ---------------------------------------------------------------- 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: us...@infra.apache.org > [YARN] New feature: custom log URL for stdout/stderr > ---------------------------------------------------- > > Key: SPARK-26311 > URL: https://issues.apache.org/jira/browse/SPARK-26311 > Project: Spark > Issue Type: Improvement > Components: YARN > Affects Versions: 2.4.0 > Reporter: Jungtaek Lim > Priority: Major > > Spark has been setting static log URLs for YARN application, which points to > NodeManager webapp. Normally it would work for both running apps and finished > apps, but there're also other approaches on maintaining application logs, > like having external log service which enables to avoid application log url > to be a deadlink when NodeManager is not accessible. (Node decommissioned, > elastic nodes, etc.) > Spark can provide a new configuration for custom log url on YARN mode, which > end users can set it properly to point application log to external log > service. -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org