Skip to content

Fix SPARK-1256: Master web UI and Worker web UI returns a 404 error #150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
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
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class MasterWebUI(val master: Master, requestedPort: Int) extends Logging {
master.applicationMetricsSystem.getServletHandlers

val handlers = metricsHandlers ++ Seq[ServletContextHandler](
createStaticHandler(MasterWebUI.STATIC_RESOURCE_DIR, "/static/*"),
createStaticHandler(MasterWebUI.STATIC_RESOURCE_DIR + "/static", "/static"),
Copy link
Contributor

Choose a reason for hiding this comment

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

You actually don't need to append "/static" to the path. Jetty is smart enough to figure it out. (Same in WorkerWebUI and SparkUI)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If so get / static / static / * resource path in jetty 9

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, what do you mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For example:

contextHandler.setContextPath(path)
contextHandler.addServlet(holder, "/")
createStaticHandler("org/apache/spark/ui", "/static") 

url http://host:port/static/spark-logo-77x50px-hd.png =>
resource path org/apache/spark/ui/spark-logo-77x50px-hd.png

14/03/19 13:35:26 DEBUG Server: REQUEST /static/spark-logo-77x50px-hd.png on HttpChannelOverHttp@5fbefaf1{r=3,a=DISPATCHED,uri=/static/spark-logo-77x50px-hd.png}
14/03/19 13:35:26 DEBUG ContextHandler: scope null||/static/spark-logo-77x50px-hd.png @ o.e.j.s.ServletContextHandler@7df5ddbe{/metrics/master/json,null,AVAILABLE}
14/03/19 13:35:26 DEBUG ContextHandler: scope null||/static/spark-logo-77x50px-hd.png @ o.e.j.s.ServletContextHandler@68ca224f{/metrics/applications/json,null,AVAILABLE}
14/03/19 13:35:26 DEBUG ContextHandler: scope null||/static/spark-logo-77x50px-hd.png @ o.e.j.s.ServletContextHandler@140dcb1a{/static,null,AVAILABLE}
14/03/19 13:35:26 DEBUG ContextHandler: context=/static||/spark-logo-77x50px-hd.png @ o.e.j.s.ServletContextHandler@140dcb1a{/static,null,AVAILABLE}
14/03/19 13:35:26 DEBUG ServletHandler: servlet /static|/spark-logo-77x50px-hd.png|null -> org.eclipse.jetty.servlet.DefaultServlet-cad7e2b@83497fc5==org.eclipse.jetty.servlet.DefaultServlet,-1,true
14/03/19 13:35:26 DEBUG ServletHandler: chain=null
14/03/19 13:35:26 DEBUG DefaultServlet: Resource /spark-logo-77x50px-hd.png=jar:file:/Users/witgo/work/code/java/spark/dist/jars/spark-assembly-1.0.0-SNAPSHOT-hadoop0.23.9.jar!/org/apache/spark/ui/spark-logo-77x50px-hd.png
14/03/19 13:35:26 DEBUG DefaultServlet: uri=/static/spark-logo-77x50px-hd.png resource=jar:file:/Users/witgo/work/code/java/spark/dist/jars/spark-assembly-1.0.0-SNAPSHOT-hadoop0.23.9.jar!/org/apache/spark/ui/spark-logo-77x50px-hd.png

createServletHandler("/app/json",
createServlet((request: HttpServletRequest) => applicationPage.renderJson(request),
master.securityMgr)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class WorkerWebUI(val worker: Worker, val workDir: File, requestedPort: Option[I
val metricsHandlers = worker.metricsSystem.getServletHandlers

val handlers = metricsHandlers ++ Seq[ServletContextHandler](
createStaticHandler(WorkerWebUI.STATIC_RESOURCE_BASE, "/static/*"),
createStaticHandler(WorkerWebUI.STATIC_RESOURCE_BASE + "/static", "/static"),
createServletHandler("/log", createServlet((request: HttpServletRequest) => log(request),
worker.securityMgr)),
createServletHandler("/logPage", createServlet((request: HttpServletRequest) => logPage
Expand Down
5 changes: 4 additions & 1 deletion core/src/main/scala/org/apache/spark/ui/JettyUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,13 @@ private[spark] object JettyUtils extends Logging {
Option(getClass.getClassLoader.getResource(resourceBase)) match {
case Some(res) =>
holder.setInitParameter("resourceBase", res.toString)
holder.setInitParameter("welcomeServlets", "false")
holder.setInitParameter("pathInfoOnly", "false")
Copy link
Contributor

Choose a reason for hiding this comment

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

I was able to get it working without these params

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These parameters allow DefaultServlet without unnecessary operations
Code in jetty
DefaultServlet L406
DefaultServlet L189

Copy link
Contributor

Choose a reason for hiding this comment

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

These parameters are already "false" by default. See L144 and L148.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes ,These parameters are already "false" by default,can be removed.

case None =>
throw new Exception("Could not find resource path for Web UI: " + resourceBase)
}
contextHandler.addServlet(holder, path)
contextHandler.setContextPath(path)
contextHandler.addServlet(holder, "/")
contextHandler
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/org/apache/spark/ui/SparkUI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private[spark] class SparkUI(sc: SparkContext) extends Logging {
var server: Option[Server] = None

val handlers = Seq[ServletContextHandler] (
createStaticHandler(SparkUI.STATIC_RESOURCE_DIR, "/static/*"),
createStaticHandler(SparkUI.STATIC_RESOURCE_DIR + "/static", "/static"),
createRedirectHandler("/stages", "/")
)
val storage = new BlockManagerUI(sc)
Expand Down