Repository: ambari
Updated Branches:
  refs/heads/trunk dacca7b5f -> b1853c2f4


AMBARI-8611 UI for pre-upgrade checks. (ababiichuk)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/b1853c2f
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/b1853c2f
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/b1853c2f

Branch: refs/heads/trunk
Commit: b1853c2f4436254e374c5af0a9d4e5ade662247d
Parents: dacca7b
Author: aBabiichuk <ababiic...@cybervisiontech.com>
Authored: Tue Dec 9 19:58:24 2014 +0200
Committer: aBabiichuk <ababiic...@cybervisiontech.com>
Committed: Wed Dec 10 15:09:37 2014 +0200

----------------------------------------------------------------------
 .../data/stack_versions/pre_upgrade_check.json  | 81 ++++++++++++++++++++
 .../main/admin/stack_and_upgrade_controller.js  | 38 +++++++++
 ambari-web/app/messages.js                      | 10 ++-
 .../stack_upgrade/pre_upgrade_check_dialog.hbs  | 29 +++++++
 .../main/admin/stack_versions/repo_versions.hbs |  2 +-
 .../admin/stack_versions/stack_versions.hbs     |  2 +-
 ambari-web/app/utils/ajax/ajax.js               |  5 +-
 .../views/main/admin/stack_and_upgrade_view.js  |  2 +-
 .../admin/stack_and_upgrade_controller_test.js  | 51 ++++++++++++
 9 files changed, 215 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b1853c2f/ambari-web/app/assets/data/stack_versions/pre_upgrade_check.json
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/data/stack_versions/pre_upgrade_check.json 
b/ambari-web/app/assets/data/stack_versions/pre_upgrade_check.json
new file mode 100644
index 0000000..81df649
--- /dev/null
+++ b/ambari-web/app/assets/data/stack_versions/pre_upgrade_check.json
@@ -0,0 +1,81 @@
+{
+  "UpgradeChecks": [
+    {
+      "check": "NameNode HA is enabled",
+      "status": "PASS",
+      "reason": "",
+      "failed_on": [],
+      "check_type": "SERVICE"
+    },
+    {
+      "check": "Work-preserving RM/NM restart is enabled in YARN configs",
+      "status": "FAIL",
+      "reason": "X should be set to Y in yarn-site",
+      "failed_on": [ "YARN" ],
+      "check_type": "SERVICE"
+    },
+    {
+      "check": "MapReduce jobs are referencing Hadoop libraries from the 
distributed cache instead of the cluster",
+      "status": "PASS",
+      "reason": "",
+      "failed_on": [],
+      "check_type": "SERVICE"
+    },
+    {
+      "check": "Tez jobs are referencing Hadoop libraries from the distributed 
cache instead of the cluster",
+      "status": "PASS",
+      "reason": "",
+      "failed_on": [],
+      "check_type": "SERVICE"
+    },
+    {
+      "check": "Oozie jobs are referencing Hadoop libraries from the 
distributed cache instead of the cluster",
+      "status": "PASS",
+      "reason": "",
+      "failed_on": [],
+      "check_type": "SERVICE"
+    },
+    {
+      "check": "All services are up",
+      "status": "FAIL",
+      "reason": "Some services are down",
+      "failed_on": [ "STORM" ],
+      "check_type": "SERVICE"
+    },
+    {
+      "check": "All services must not in Maintenance Mode",
+      "status": "FAIL",
+      "reason": "Some services are in Maintenance Mode",
+      "failed_on": [ "FALCON", "OOZIE" ],
+      "check_type": "SERVICE"
+    },
+    {
+      "check": "There must not be any DataNodes in decommissioning state",
+      "status": "FAIL",
+      "reason": "Some DataNodes are in decommissioning state",
+      "failed_on": [ "host004", "host005" ],
+      "check_type": "HOST"
+    },
+    {
+      "check": "All hosts must be heartbeating with the server unless they are 
in Maintenance Mode",
+      "status": "FAIL",
+      "reason": "Some hosts are not heartbeating with the server",
+      "failed_on": [ "host009", "host010" ],
+      "check_type": "HOST"
+    },
+    {
+      "check": "All hosts must not have any components in Maintenance Mode",
+      "status": "FAIL",
+      "reason": "Some hosts have host components in Maintenance Mode",
+      "failed_on": [ "host001", "host002" ],
+      "check_type": "HOST"
+    },
+    {
+      "check": "All hosts must have the new version installed",
+      "status": "FAIL",
+      "reason": "Some hosts do not have HDP-2.2.1 installed",
+      "failed_on": [ "host001", "host002" ],
+      "check_type": "HOST"
+    }
+  ]
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/b1853c2f/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
----------------------------------------------------------------------
diff --git 
a/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js 
b/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
index 159b525..f8c687e 100644
--- a/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
+++ b/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
@@ -208,6 +208,44 @@ App.MainAdminStackAndUpgradeController = 
Em.Controller.extend(App.LocalStorage,
   },
 
   /**
+   * send request for pre upgrade check
+   * @param version
+   */
+  runPreUpgradeCheck: function(version) {
+    App.ajax.send({
+      name: "admin.rolling_upgrade.pre_upgrade_check",
+      sender: this,
+      data: version,
+      success: "runPreUpgradeCheckSuccess"
+    })
+  },
+
+  /**
+   * success callback of <code>runPreUpgradeCheckSuccess()</code>
+   * if there are some fails - it shows popup else run upgrade
+   * @param data {object}
+   * @param opt {object}
+   * @param params {object}
+   * @returns {App.ModalPopup|void}
+   */
+  runPreUpgradeCheckSuccess: function(data, opt, params) {
+    if (data.UpgradeChecks.someProperty('status',"FAIL")) {
+      return App.ModalPopup.show({
+        header: 
Em.I18n.t('admin.stackUpgrade.preupgradeCheck.header').format(params.label),
+        primary: Em.I18n.t('common.dismiss'),
+        secondary: false,
+        bodyClass: Em.View.extend({
+          templateName: 
require('templates/main/admin/stack_upgrade/pre_upgrade_check_dialog'),
+          checks: function() {
+            return data.UpgradeChecks.filterProperty('status',"FAIL");
+          }.property()
+        })
+      })
+    } else {
+      this.upgrade(params);
+    }
+  },
+  /**
    * make call to resume upgrade process and show popup with current progress
    */
   resumeUpgrade: function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/b1853c2f/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index d0a58f6..1d074e7 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -242,6 +242,7 @@ Em.I18n.translations = {
   'common.prerequisites': 'Prerequisites',
   'common.finalize': "Finalize",
   'common.severity': "Severity",
+  'common.dismiss': "Dismiss",
 
   'models.alert_instance.tiggered.verbose': "Occured on {0} <br> Checked on 
{1}",
   'models.alert_definition.triggered.verbose': "Occured on {0}",
@@ -1268,6 +1269,8 @@ Em.I18n.translations = {
   'admin.stackVersions.table.header.os': "OS",
   'admin.stackVersions.table.header.installed': "Installed on",
   'admin.stackVersions.table.header.current': "Current on",
+  'admin.stackVersions.table.empty': "No cluster stack versions to display",
+  'admin.repoVersions.table.empty': "No repository versions to display",
 
   'admin.stackVersions.datails.versionName': "Version Name",
   'admin.stackVersions.datails.installed.on': "Installed On",
@@ -1309,7 +1312,12 @@ Em.I18n.translations = {
   'admin.stackUpgrade.dialog.manualDone': "I have preformed the manual steps 
above.",
   'admin.stackUpgrade.dialog.closeProgress': "Upgrade is in progress. \n If 
you dismiss this window, Upgrade will keep running in background.",
   'admin.stackUpgrade.dialog.closePause': "Upgrade is paused. \n If you 
dismiss this window, you can resume Upgrade later.",
-
+  'admin.stackUpgrade.preupgradeCheck.header': "Upgrade to {0}",
+  'admin.stackUpgrade.preupgradeCheck.title': "Upgrade Requirements Not Met",
+  'admin.stackUpgrade.preupgradeCheck.alert': "You have not met the following 
requirements for performing on upgrade.<br/>"+
+    "You must fix them before you continue",
+  'admin.stackUpgrade.preupgradeCheck.failedOn': "Failed on: ",
+  'admin.stackUpgrade.preupgradeCheck.reason': "Reason: ",
   'services.service.start':'Start',
   'services.service.stop':'Stop',
   'services.service.metrics':'Metrics',

http://git-wip-us.apache.org/repos/asf/ambari/blob/b1853c2f/ambari-web/app/templates/main/admin/stack_upgrade/pre_upgrade_check_dialog.hbs
----------------------------------------------------------------------
diff --git 
a/ambari-web/app/templates/main/admin/stack_upgrade/pre_upgrade_check_dialog.hbs
 
b/ambari-web/app/templates/main/admin/stack_upgrade/pre_upgrade_check_dialog.hbs
new file mode 100644
index 0000000..4a6af6a
--- /dev/null
+++ 
b/ambari-web/app/templates/main/admin/stack_upgrade/pre_upgrade_check_dialog.hbs
@@ -0,0 +1,29 @@
+{{!
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+}}
+<div id="pre-upgrade-check">
+  <h4>{{t admin.stackUpgrade.preupgradeCheck.title}}</h4>
+  <div class="alert alert-warning">
+    {{t admin.stackUpgrade.preupgradeCheck.alert}}
+  </div>
+  <div class="limited-height-2">
+    {{#each item in view.checks}}
+        <i class="icon-remove"></i>&nbsp;<span>{{item.check}}</span>
+        <pre>{{t 
admin.stackUpgrade.preupgradeCheck.reason}}{{item.reason}}<br/>{{t 
admin.stackUpgrade.preupgradeCheck.failedOn}}{{item.failed_on}}</pre>
+    {{/each}}
+  </div>
+</div>

http://git-wip-us.apache.org/repos/asf/ambari/blob/b1853c2f/ambari-web/app/templates/main/admin/stack_versions/repo_versions.hbs
----------------------------------------------------------------------
diff --git 
a/ambari-web/app/templates/main/admin/stack_versions/repo_versions.hbs 
b/ambari-web/app/templates/main/admin/stack_versions/repo_versions.hbs
index 1a48016..a49b813 100644
--- a/ambari-web/app/templates/main/admin/stack_versions/repo_versions.hbs
+++ b/ambari-web/app/templates/main/admin/stack_versions/repo_versions.hbs
@@ -61,7 +61,7 @@
       {{else}}
         <tr>
           <td class="first empty-table" colspan="4">
-            {{t dashboard.configHistory.table.empty}}
+            {{t admin.repoVersions.table.empty}}
           </td>
         </tr>
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/b1853c2f/ambari-web/app/templates/main/admin/stack_versions/stack_versions.hbs
----------------------------------------------------------------------
diff --git 
a/ambari-web/app/templates/main/admin/stack_versions/stack_versions.hbs 
b/ambari-web/app/templates/main/admin/stack_versions/stack_versions.hbs
index dd6a99d..facc623 100644
--- a/ambari-web/app/templates/main/admin/stack_versions/stack_versions.hbs
+++ b/ambari-web/app/templates/main/admin/stack_versions/stack_versions.hbs
@@ -76,7 +76,7 @@
       {{else}}
         <tr>
           <td class="first empty-table" colspan="5">
-            {{t dashboard.configHistory.table.empty}}
+            {{t admin.stackVersions.table.empty}}
           </td>
         </tr>
       {{/if}}

http://git-wip-us.apache.org/repos/asf/ambari/blob/b1853c2f/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js 
b/ambari-web/app/utils/ajax/ajax.js
index fdb59a4..7aa5fbd 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -1379,7 +1379,10 @@ var urls = {
     },
     'mock': ''
   },
-
+  'admin.rolling_upgrade.pre_upgrade_check': {
+    'real': '/clusters/{clusterName}/rolling_upgrades_check',
+    'mock': '/data/stack_versions/pre_upgrade_check.json'
+  },
 
   'wizard.advanced_repositories.valid_url': {
     'real': 
'/stacks/{stackName}/versions/{stackVersion}/operating_systems/{osType}/repositories/{repoId}',

http://git-wip-us.apache.org/repos/asf/ambari/blob/b1853c2f/ambari-web/app/views/main/admin/stack_and_upgrade_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/admin/stack_and_upgrade_view.js 
b/ambari-web/app/views/main/admin/stack_and_upgrade_view.js
index 5c5a604..c983a71 100644
--- a/ambari-web/app/views/main/admin/stack_and_upgrade_view.js
+++ b/ambari-web/app/views/main/admin/stack_and_upgrade_view.js
@@ -179,7 +179,7 @@ App.MainAdminStackAndUpgradeView = Em.View.extend({
         case 'INIT':
           if (this.get('versions.length') > 0) {
             label = Em.I18n.t('common.upgrade');
-            method = 'upgrade';
+            method = 'runPreUpgradeCheck';
           }
           break;
         case 'PENDING':

http://git-wip-us.apache.org/repos/asf/ambari/blob/b1853c2f/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
----------------------------------------------------------------------
diff --git 
a/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js 
b/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
index 64a9c7b..104dfca 100644
--- 
a/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
+++ 
b/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
@@ -217,4 +217,55 @@ describe('App.MainAdminStackAndUpgradeController', 
function() {
       
expect(App.router.transitionTo.calledWith('admin.stackUpgrade')).to.be.true;
     });
   });
+
+
+  describe("#runPreUpgradeCheck()", function() {
+    before(function () {
+      sinon.stub(App.ajax, 'send', Em.K);
+    });
+    after(function () {
+      App.ajax.send.restore();
+    });
+    it("make ajax call", function() {
+      controller.runPreUpgradeCheck("2.2.1");
+      expect(App.ajax.send.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#runPreUpgradeCheckSuccess()", function () {
+    beforeEach(function () {
+      sinon.stub(App.ModalPopup, 'show', Em.K);
+      sinon.stub(controller, 'upgrade', Em.K);
+    });
+    afterEach(function () {
+      App.ModalPopup.show.restore();
+      controller.upgrade.restore();
+    });
+    it("shows popup", function () {
+      var check =  {UpgradeChecks: [{
+        "check": "Work-preserving RM/NM restart is enabled in YARN configs",
+        "status": "FAIL",
+        "reason": "FAIL",
+        "failed_on": [],
+        "check_type": "SERVICE"
+      }]};
+      controller.runPreUpgradeCheckSuccess(check,null,{label: "name"});
+      expect(controller.upgrade.calledOnce).to.be.false;
+      expect(App.ModalPopup.show.calledOnce).to.be.true;
+    });
+    it("runs upgrade popup", function () {
+      var check = {UpgradeChecks: [{
+        "check": "Work-preserving RM/NM restart is enabled in YARN configs",
+        "status": "PASS",
+        "reason": "OK",
+        "failed_on": [],
+        "check_type": "SERVICE"
+      }]};
+      controller.runPreUpgradeCheckSuccess(check,null,{label: "name"});
+      expect(controller.upgrade.calledOnce).to.be.true;
+      expect(App.ModalPopup.show.calledOnce).to.be.false;
+    });
+  });
+
+
 });

Reply via email to