Skip to content
Snippets Groups Projects
Commit efc72dcc authored by Oliver Köth's avatar Oliver Köth Committed by Sean Owen
Browse files

[SPARK-20042][WEB UI] Fix log page buttons for reverse proxy mode


with spark.ui.reverseProxy=true, full path URLs like /log will point to
the master web endpoint which is serving the worker UI as reverse proxy.
To access a REST endpoint in the worker in reverse proxy mode , the
leading /proxy/"target"/ part of the base URI must be retained.

Added logic to log-view.js to handle this, similar to executorspage.js

Patch was tested manually

Author: Oliver Köth <okoeth@de.ibm.com>

Closes #17370 from okoethibm/master.

(cherry picked from commit 6f09dc70)
Signed-off-by: default avatarSean Owen <sowen@cloudera.com>
parent 00c12488
No related branches found
No related tags found
No related merge requests found
...@@ -51,13 +51,26 @@ function noNewAlert() { ...@@ -51,13 +51,26 @@ function noNewAlert() {
window.setTimeout(function () {alert.css("display", "none");}, 4000); window.setTimeout(function () {alert.css("display", "none");}, 4000);
} }
function getRESTEndPoint() {
// If the worker is served from the master through a proxy (see doc on spark.ui.reverseProxy),
// we need to retain the leading ../proxy/<workerid>/ part of the URL when making REST requests.
// Similar logic is contained in executorspage.js function createRESTEndPoint.
var words = document.baseURI.split('/');
var ind = words.indexOf("proxy");
if (ind > 0) {
return words.slice(0, ind + 2).join('/') + "/log";
}
return "/log"
}
function loadMore() { function loadMore() {
var offset = Math.max(startByte - byteLength, 0); var offset = Math.max(startByte - byteLength, 0);
var moreByteLength = Math.min(byteLength, startByte); var moreByteLength = Math.min(byteLength, startByte);
$.ajax({ $.ajax({
type: "GET", type: "GET",
url: "/log" + baseParams + "&offset=" + offset + "&byteLength=" + moreByteLength, url: getRESTEndPoint() + baseParams + "&offset=" + offset + "&byteLength=" + moreByteLength,
success: function (data) { success: function (data) {
var oldHeight = $(".log-content")[0].scrollHeight; var oldHeight = $(".log-content")[0].scrollHeight;
var newlineIndex = data.indexOf('\n'); var newlineIndex = data.indexOf('\n');
...@@ -83,14 +96,14 @@ function loadMore() { ...@@ -83,14 +96,14 @@ function loadMore() {
function loadNew() { function loadNew() {
$.ajax({ $.ajax({
type: "GET", type: "GET",
url: "/log" + baseParams + "&byteLength=0", url: getRESTEndPoint() + baseParams + "&byteLength=0",
success: function (data) { success: function (data) {
var dataInfo = data.substring(0, data.indexOf('\n')).match(/\d+/g); var dataInfo = data.substring(0, data.indexOf('\n')).match(/\d+/g);
var newDataLen = dataInfo[2] - totalLogLength; var newDataLen = dataInfo[2] - totalLogLength;
if (newDataLen != 0) { if (newDataLen != 0) {
$.ajax({ $.ajax({
type: "GET", type: "GET",
url: "/log" + baseParams + "&byteLength=" + newDataLen, url: getRESTEndPoint() + baseParams + "&byteLength=" + newDataLen,
success: function (data) { success: function (data) {
var newlineIndex = data.indexOf('\n'); var newlineIndex = data.indexOf('\n');
var dataInfo = data.substring(0, newlineIndex).match(/\d+/g); var dataInfo = data.substring(0, newlineIndex).match(/\d+/g);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment