From 7802af6e9a85f033e9515cc7b23c125a0e06c325 Mon Sep 17 00:00:00 2001 From: Eric Yang Date: Thu, 17 May 2018 17:06:58 -0400 Subject: [PATCH] YARN-8293. Removed "User Name for service" for deploying secure YARN service. Contributed by Sunil G --- .../webapp/app/adapters/yarn-servicedef.js | 4 ++- .../webapp/app/components/deploy-service.js | 5 +++ .../main/webapp/app/initializers/loader.js | 32 +++++++++++++++++++ .../src/main/webapp/app/services/hosts.js | 5 +++ .../templates/components/deploy-service.hbs | 18 ++++++----- .../src/main/webapp/config/default-config.js | 3 +- 6 files changed, 57 insertions(+), 10 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-servicedef.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-servicedef.js index 03685fb22c..9000d7429a 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-servicedef.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/adapters/yarn-servicedef.js @@ -26,7 +26,9 @@ export default RESTAbstractAdapter.extend({ deployService(request, user) { var url = this.buildURL(); - url += "/?user.name=" + user; + if(user) { + url += "/?user.name=" + user; + } return this.ajax(url, "POST", {data: request}); }, diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/components/deploy-service.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/components/deploy-service.js index 36895d72f1..18e4d36b81 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/components/deploy-service.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/components/deploy-service.js @@ -28,6 +28,7 @@ export default Ember.Component.extend({ serviceResp: null, isLoading: false, userName: '', + hosts: Ember.inject.service('hosts'), actions: { showSaveTemplateModal() { @@ -157,6 +158,10 @@ export default Ember.Component.extend({ isValidCustomServiceDef: Ember.computed.notEmpty('customServiceDef'), + isSecurityNotEnabled: Ember.computed('isSecurityEnabled', function () { + return this.get(`hosts.isSecurityEnabled`) === 'simple'; + }), + enableSaveOrDeployBtn: Ember.computed('isValidServiceDef', 'isValidCustomServiceDef', 'viewType', 'isLoading', 'isUserNameGiven', function() { if (this.get('isLoading')) { return false; 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 43b50653ec..53f9c444c9 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 @@ -75,6 +75,15 @@ function getTimeLineV1URL(rmhost, isHttpsSchemeEnabled) { return url; } +function getSecurityURL(rmhost) { + var url = window.location.protocol + '//' + + (ENV.hosts.localBaseAddress? ENV.hosts.localBaseAddress + '/' : '') + rmhost; + + url += '/conf?name=hadoop.security.authentication'; + Ember.Logger.log("Server security mode url is: " + url); + return url; +} + function updateConfigs(application) { var hostname = window.location.hostname; var rmhost = hostname + (window.location.port ? ':' + window.location.port: '') + skipTrailingSlash(window.location.pathname); @@ -156,6 +165,29 @@ function updateConfigs(application) { Ember.Logger.log("Timeline V1 Address: " + ENV.hosts.timelineV1WebAddress); application.advanceReadiness(); } + + if(!ENV.hosts.isSecurityEnabled) { + var isSecurityEnabled = ""; + $.ajax({ + type: 'GET', + dataType: 'json', + async: true, + context: this, + url: getSecurityURL(rmhost), + success: function(data) { + isSecurityEnabled = data.property.value; + ENV.hosts.isSecurityEnabled = isSecurityEnabled; + Ember.Logger.log("Security mode is : " + isSecurityEnabled); + application.advanceReadiness(); + }, + error: function() { + application.advanceReadiness(); + } + }); + } else { + Ember.Logger.log("Security mode is: " + ENV.hosts.isSecurityEnabled); + application.advanceReadiness(); + } } export function initialize( application ) { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/services/hosts.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/services/hosts.js index 738f5f16ca..a53451b86f 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/services/hosts.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/services/hosts.js @@ -82,5 +82,10 @@ export default Ember.Service.extend({ dashWebAddress: Ember.computed(function () { return this.normalizeURL(this.get("env.app.hosts.dashWebAddress")); + }), + + isSecurityEnabled: Ember.computed(function () { + console.log(this.get("env.app.hosts.isSecurityEnabled")); + return this.get("env.app.hosts.isSecurityEnabled"); }) }); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/components/deploy-service.hbs b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/components/deploy-service.hbs index 720074e0c4..2d186106b4 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/components/deploy-service.hbs +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/components/deploy-service.hbs @@ -29,16 +29,18 @@ {{/if}} -
-
-
- - - {{input type="text" class="form-control" placeholder="User Name" value=userName}} + {{#if isSecurityNotEnabled}} +
+
+
+ + + {{input type="text" class="form-control" placeholder="User Name" value=userName}} +
+
-
-
+ {{/if}}
{{#if isLoading}} Loading... diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/config/default-config.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/config/default-config.js index ff95115e90..3d3779650a 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/config/default-config.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/config/default-config.js @@ -22,7 +22,8 @@ module.exports = { // YARN UI App configurations timelineWebAddress: "localhost:8188", timelineV1WebAddress: "localhost:8188", rmWebAddress: "localhost:8088", - protocolScheme: "http:" + protocolScheme: "http:", + isSecurityEnabled: "" }, namespaces: { timeline: 'ws/v1/applicationhistory',