From c95795cd8f649c45f05df1d5faa1dcabd30d7a6e Mon Sep 17 00:00:00 2001 From: Rohith Sharma K S Date: Thu, 17 May 2018 16:24:51 +0530 Subject: [PATCH] YARN-8297. Incorrect ATS Url used for Wire encrypted cluster. Contributed by Sunil G. --- .../main/webapp/app/initializers/loader.js | 50 ++++++++++++++++--- 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/initializers/loader.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/initializers/loader.js index 83df971d9d..43b50653ec 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/initializers/loader.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/initializers/loader.js @@ -20,20 +20,57 @@ import Ember from 'ember'; -function getTimeLineURL(rmhost) { +function getYarnHttpProtocolScheme(rmhost, application) { + var httpUrl = window.location.protocol + '//' + + (ENV.hosts.localBaseAddress? ENV.hosts.localBaseAddress + '/' : '') + rmhost; + + httpUrl += '/conf?name=yarn.http.policy'; + Ember.Logger.log("yarn.http.policy URL is: " + httpUrl); + + var protocolScheme = ""; + $.ajax({ + type: 'GET', + dataType: 'json', + async: true, + context: this, + url: httpUrl, + success: function(data) { + protocolScheme = data.property.value; + Ember.Logger.log("Protocol scheme from RM: " + protocolScheme); + + application.advanceReadiness(); + }, + error: function() { + application.advanceReadiness(); + } + }); + return protocolScheme == "HTTPS_ONLY"; +} + +function getTimeLineURL(rmhost, isHttpsSchemeEnabled) { var url = window.location.protocol + '//' + (ENV.hosts.localBaseAddress? ENV.hosts.localBaseAddress + '/' : '') + rmhost; - url += '/conf?name=yarn.timeline-service.reader.webapp.address'; + if(isHttpsSchemeEnabled) { + url += '/conf?name=yarn.timeline-service.reader.webapp.https.address'; + } else { + url += '/conf?name=yarn.timeline-service.reader.webapp.address'; + } + Ember.Logger.log("Get Timeline V2 Address URL: " + url); return url; } -function getTimeLineV1URL(rmhost) { +function getTimeLineV1URL(rmhost, isHttpsSchemeEnabled) { var url = window.location.protocol + '//' + (ENV.hosts.localBaseAddress? ENV.hosts.localBaseAddress + '/' : '') + rmhost; - url += '/conf?name=yarn.timeline-service.webapp.address'; + if(isHttpsSchemeEnabled) { + url += '/conf?name=yarn.timeline-service.webapp.https.address'; + } else { + url += '/conf?name=yarn.timeline-service.webapp.address'; + } + Ember.Logger.log("Get Timeline V1 Address URL: " + url); return url; } @@ -51,6 +88,7 @@ function updateConfigs(application) { Ember.Logger.log("RM Address: " + rmhost); + var isHttpsSchemeEnabled = getYarnHttpProtocolScheme(rmhost, application); if(!ENV.hosts.timelineWebAddress) { var timelinehost = ""; $.ajax({ @@ -58,7 +96,7 @@ function updateConfigs(application) { dataType: 'json', async: true, context: this, - url: getTimeLineURL(rmhost), + url: getTimeLineURL(rmhost, isHttpsSchemeEnabled), success: function(data) { timelinehost = data.property.value; timelinehost = timelinehost.replace(/(^\w+:|^)\/\//, ''); @@ -92,7 +130,7 @@ function updateConfigs(application) { dataType: 'json', async: true, context: this, - url: getTimeLineV1URL(rmhost), + url: getTimeLineV1URL(rmhost, isHttpsSchemeEnabled), success: function(data) { timelinehost = data.property.value; timelinehost = timelinehost.replace(/(^\w+:|^)\/\//, '');