Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions core/src/main/scala/org/apache/spark/SparkContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -592,9 +592,8 @@ class SparkContext(config: SparkConf) extends Logging {
_env.blockManager.blockStoreClient.setAppAttemptId(attemptId)
}
if (_conf.get(UI_REVERSE_PROXY)) {
val proxyUrl = _conf.get(UI_REVERSE_PROXY_URL.key, "").stripSuffix("/") +
"/proxy/" + _applicationId
System.setProperty("spark.ui.proxyBase", proxyUrl)
val proxyUrl = _conf.get(UI_REVERSE_PROXY_URL).getOrElse("").stripSuffix("/")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to get the ConfigEntry to trigger the checkValue method.

System.setProperty("spark.ui.proxyBase", proxyUrl + "/proxy/" + _applicationId)
}
_ui.foreach(_.setAppId(_applicationId))
_env.blockManager.initialize(_applicationId)
Expand Down
5 changes: 5 additions & 0 deletions core/src/main/scala/org/apache/spark/internal/config/UI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ private[spark] object UI {
"reach your proxy.")
.version("2.1.0")
.stringConf
.checkValue ({ s =>
val words = s.split("/")
!words.contains("proxy") && !words.contains("history") },
"Cannot use the keyword 'proxy' or 'history' in reverse proxy URL. Spark UI relies on both " +
"keywords for getting REST API endpoints from URIs.")
.createOptional

val UI_KILL_ENABLED = ConfigBuilder("spark.ui.killEnabled")
Expand Down
11 changes: 11 additions & 0 deletions core/src/test/scala/org/apache/spark/SparkContextSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1343,6 +1343,17 @@ class SparkContextSuite extends SparkFunSuite with LocalSparkContext with Eventu
assert(env.blockManager.blockStoreClient.getAppAttemptId.equals("1"))
}

test("SPARK-34659: check invalid UI_REVERSE_PROXY_URL") {
val reverseProxyUrl = "http://proxyhost:8080/path/proxy/spark"
val conf = new SparkConf().setAppName("testAppAttemptId")
.setMaster("pushbasedshuffleclustermanager")
conf.set(UI_REVERSE_PROXY, true)
conf.set(UI_REVERSE_PROXY_URL, reverseProxyUrl)
val msg = intercept[java.lang.IllegalArgumentException] {
new SparkContext(conf)
}.getMessage
assert(msg.contains("Cannot use the keyword 'proxy' or 'history' in reverse proxy URL"))
}
}

object SparkContextSuite {
Expand Down
4 changes: 3 additions & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -1324,7 +1324,9 @@ Apart from these, the following properties are also available, and may be useful
This setting affects all the workers and application UIs running in the cluster and must be set
identically on all the workers, drivers and masters. In is only effective when
<code>spark.ui.reverseProxy</code> is turned on. This setting is not needed when the Spark
master web UI is directly reachable. </td>
master web UI is directly reachable.<br/>
Note that the value of the setting can't contain the keyword `proxy` or `history` after split by "/". Spark UI relies on both keywords for getting REST API endpoints from URIs.
</td>
<td>2.1.0</td>
</tr>
<tr>
Expand Down