ソースを参照

YARN-8297. Incorrect ATS Url used for Wire encrypted cluster. Contributed by Sunil G.

(cherry picked from commit c95795cd8f649c45f05df1d5faa1dcabd30d7a6e)
Rohith Sharma K S 7 年 前
コミット
4222e8f21b

+ 44 - 6
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+:|^)\/\//, '');