From 9548338139f541307481860b6c72e9c0ddbe476d Mon Sep 17 00:00:00 2001 From: Arata Furukawa Date: Mon, 8 Mar 2021 12:04:32 +0900 Subject: [PATCH] Fix that Web UI always correctly get appId MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Web UI does not correctly get appId when it has `proxy` or `history` in URL.  In my case, it's happened on `https://jupyterhub.hosted.our/my-name/proxy/4040/executors/`. There is relative issue in jupyterhub https://github.com/jupyterhub/jupyter-server-proxy/issues/57 It should not get appId from document.BaseURI. A request will occur, but performance impacts will be a bit. --- .../org/apache/spark/ui/static/utils.js | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/core/src/main/resources/org/apache/spark/ui/static/utils.js b/core/src/main/resources/org/apache/spark/ui/static/utils.js index 1bec1c174df5a..43b9ef792d064 100644 --- a/core/src/main/resources/org/apache/spark/ui/static/utils.js +++ b/core/src/main/resources/org/apache/spark/ui/static/utils.js @@ -96,20 +96,6 @@ function formatLogsCells(execLogs, type) { } function getStandAloneAppId(cb) { - var words = getBaseURI().split('/'); - var ind = words.indexOf("proxy"); - var appId; - if (ind > 0) { - appId = words[ind + 1]; - cb(appId); - return; - } - ind = words.indexOf("history"); - if (ind > 0) { - appId = words[ind + 1]; - cb(appId); - return; - } // Looks like Web UI is running in standalone mode // Let's get application-id using REST End Point $.getJSON(uiRoot + "/api/v1/applications", function(response, status, jqXHR) { @@ -117,6 +103,20 @@ function getStandAloneAppId(cb) { var appId = response[0].id; cb(appId); return; + } else { + var words = document.baseURI.split('/'); + var ind = words.indexOf("proxy"); + if (ind > 0) { + var appId = words[ind + 1]; + cb(appId); + return; + } + ind = words.indexOf("history"); + if (ind > 0) { + var appId = words[ind + 1]; + cb(appId) + return; + } } }); } @@ -231,4 +231,4 @@ function createRESTEndPointForMiscellaneousProcess(appId) { function getBaseURI() { return document.baseURI || document.URL; } -/* eslint-enable no-unused-vars */ \ No newline at end of file +/* eslint-enable no-unused-vars */