浏览代码

[ui] Spark application history links not working when Knox is enabled (#2859)

The spark application trackingUrl was pointing to the original url even
when Knox was enabled.

This change rewrites the trackingUrl with the knox url to the corresponding
YARN application url (yarnuiv2) when Knox is enabled.
Amit S 3 年之前
父节点
当前提交
7cb46979ee
共有 1 个文件被更改,包括 23 次插入0 次删除
  1. 23 0
      apps/jobbrowser/src/jobbrowser/templates/job_browser.mako

+ 23 - 0
apps/jobbrowser/src/jobbrowser/templates/job_browser.mako

@@ -3026,6 +3026,25 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
         });
       };
 
+      self._rewriteKnoxUrls = function (data) {
+        if (data && data.app && data.app.type === 'SPARK' && data.app.properties && data.app.properties.metadata) {
+          data.app.properties.metadata.forEach(function (item) {
+            if (item.name === 'trackingUrl') {
+              /*
+                Rewrite tracking url
+                Sample trackingUrl: http://<yarn>:8088/proxy/application_1652826179847_0003/
+                Knox URL: https://<knox-base>/yarnuiv2/redirect#/yarn-app/application_1652826179847_0003/attempts
+              */
+              var matches = item.value.match('(application_[0-9_]+)');
+              if (matches && matches.length > 1) {
+                var applicationId = matches[1];
+                item.value = window.KNOX_BASE_URL + '/yarnuiv2/redirect#/yarn-app/' + applicationId + '/attempts';
+              }
+            }
+            return;
+          });
+        }
+      }
       self.fetchJob = function () {
         // TODO: Remove cancelActiveRequest from apiHelper when in webpack
         vm.apiHelper.cancelActiveRequest(lastFetchJobRequest);
@@ -3079,6 +3098,10 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
 
         lastFetchJobRequest = self._fetchJob(function (data) {
           if (data.status == 0) {
+            if (window.KNOX_BASE_URL && window.KNOX_BASE_URL.length) {
+              self._rewriteKnoxUrls(data);
+            }
+
             vm.interface(interface);
             vm.job(new Job(vm, data.app));
             if (window.location.hash !== '#!id=' + vm.job().id()) {