You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by sa...@apache.org on 2020/11/30 10:35:46 UTC

[spark] branch branch-3.0 updated: [SPARK-33579][UI] Fix executor blank page behind proxy

This is an automated email from the ASF dual-hosted git repository.

sarutak pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-3.0 by this push:
     new f6638cf  [SPARK-33579][UI] Fix executor blank page behind proxy
f6638cf is described below

commit f6638cfd624ee3b31f68e3d2b539dbae351730a4
Author: Pascal Gillet <pa...@stack-labs.com>
AuthorDate: Mon Nov 30 19:31:42 2020 +0900

    [SPARK-33579][UI] Fix executor blank page behind proxy
    
    ### What changes were proposed in this pull request?
    
    Fix some "hardcoded" API urls in Web UI.
    More specifically, we avoid the use of `location.origin` when constructing URLs for internal API calls within the JavaScript.
    Instead, we use `apiRoot` global variable.
    
    ### Why are the changes needed?
    
    On one hand, it allows us to build relative URLs. On the other hand, `apiRoot` reflects the Spark property `spark.ui.proxyBase` which can be set to change the root path of the Web UI.
    
    If `spark.ui.proxyBase` is actually set, original URLs become incorrect, and we end up with an executors blank page.
    I encounter this bug when accessing the Web UI behind a proxy (in my case a Kubernetes Ingress).
    
    See the following link for more context:
    https://github.com/jupyterhub/jupyter-server-proxy/issues/57#issuecomment-699163115
    
    ### Does this PR introduce _any_ user-facing change?
    
    Yes, as all the changes introduced are in the JavaScript for the Web UI.
    
    ### How the changes have been tested ?
    I modified/debugged the JavaScript as in the commit with the help of the developer tools in Google Chrome, while accessing the Web UI of my Spark app behind my k8s ingress.
    
    Closes #30523 from pgillet/fix-executors-blank-page-behind-proxy.
    
    Authored-by: Pascal Gillet <pa...@stack-labs.com>
    Signed-off-by: Kousuke Saruta <sa...@oss.nttdata.com>
    (cherry picked from commit 6e5446e61f278e9afac342e8f33905f5630aa7d5)
    Signed-off-by: Kousuke Saruta <sa...@oss.nttdata.com>
---
 core/src/main/resources/org/apache/spark/ui/static/stagepage.js | 2 +-
 core/src/main/resources/org/apache/spark/ui/static/utils.js     | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/core/src/main/resources/org/apache/spark/ui/static/stagepage.js b/core/src/main/resources/org/apache/spark/ui/static/stagepage.js
index ee2b7b3..b296495 100644
--- a/core/src/main/resources/org/apache/spark/ui/static/stagepage.js
+++ b/core/src/main/resources/org/apache/spark/ui/static/stagepage.js
@@ -70,7 +70,7 @@ function stageEndPoint(appId) {
             return newBaseURI + "/api/v1/applications/" + appId + "/" + appAttemptId + "/stages/" + stageId;
         }
     }
-    return location.origin + "/api/v1/applications/" + appId + "/stages/" + stageId;
+    return uiRoot + "/api/v1/applications/" + appId + "/stages/" + stageId;
 }
 
 function getColumnNameForTaskMetricSummary(columnKey) {
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 2e46111..d15d003 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
@@ -105,7 +105,7 @@ function getStandAloneAppId(cb) {
   }
   // Looks like Web UI is running in standalone mode
   // Let's get application-id using REST End Point
-  $.getJSON(location.origin + "/api/v1/applications", function(response, status, jqXHR) {
+  $.getJSON(uiRoot + "/api/v1/applications", function(response, status, jqXHR) {
     if (response && response.length > 0) {
       var appId = response[0].id;
       cb(appId);
@@ -152,7 +152,7 @@ function createTemplateURI(appId, templateName) {
     var baseURI = words.slice(0, ind).join('/') + '/static/' + templateName + '-template.html';
     return baseURI;
   }
-  return location.origin + "/static/" + templateName + "-template.html";
+  return uiRoot + "/static/" + templateName + "-template.html";
 }
 
 function setDataTableDefaults() {
@@ -190,5 +190,5 @@ function createRESTEndPointForExecutorsPage(appId) {
             return newBaseURI + "/api/v1/applications/" + appId + "/" + attemptId + "/allexecutors";
         }
     }
-    return location.origin + "/api/v1/applications/" + appId + "/allexecutors";
+    return uiRoot + "/api/v1/applications/" + appId + "/allexecutors";
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org