ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From onechipore...@apache.org
Subject ambari git commit: AMBARI-12879. Warn the user about HDFS Upgrade not finalized in Ambari Web UI (onechiporenko)
Date Wed, 26 Aug 2015 11:38:28 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk adc32c91e -> 5d159a376


AMBARI-12879. Warn the user about HDFS Upgrade not finalized in Ambari Web UI (onechiporenko)


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

Branch: refs/heads/trunk
Commit: 5d159a376d2315f08aa579e47bf35a1fa2d3c47b
Parents: adc32c9
Author: Oleg Nechiporenko <onechiporenko@apache.org>
Authored: Wed Aug 26 14:27:05 2015 +0300
Committer: Oleg Nechiporenko <onechiporenko@apache.org>
Committed: Wed Aug 26 14:37:39 2015 +0300

----------------------------------------------------------------------
 .../main/admin/stack_and_upgrade_controller.js  | 46 ++++++++++
 ambari-web/app/messages.js                      |  1 +
 ambari-web/app/styles/application.less          |  2 +-
 ambari-web/app/templates/application.hbs        |  7 +-
 ambari-web/app/utils/ajax/ajax.js               |  4 +
 .../admin/stack_upgrade/upgrade_wizard_view.js  |  2 +-
 .../admin/stack_and_upgrade_controller_test.js  | 91 +++++++++++++++++++-
 .../stack_upgrade/upgrade_wizard_view_test.js   |  3 +-
 8 files changed, 151 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/5d159a37/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 e9829ce..fa5b479 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
@@ -83,6 +83,18 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
    */
   taskDetailsProperties: ['status', 'stdout', 'stderr', 'error_log', 'host_name', 'output_log'],
 
+  /**
+   * Context for Finalize item
+   * @type {string}
+   */
+  finalizeContext: 'Confirm Finalize',
+
+  /**
+   * Check if current item is Finalize
+   * @type {boolean}
+   */
+  isFinalizeItem: false,
+
   isLoadUpgradeDataPending: false,
 
   /**
@@ -798,6 +810,40 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
   }.observes('App.upgradeState'),
 
   /**
+   * Check <code>App.upgradeState</code> for HOLDING
+   * If it is, send request to check if current item is Finalize
+   * @method updateFinalize
+   */
+  updateFinalize: function () {
+    var upgradeState = App.get('upgradeState');
+    if (upgradeState === 'HOLDING') {
+      return App.ajax.send({
+        name: 'admin.upgrade.finalizeContext',
+        sender: this,
+        success: 'updateFinalizeSuccessCallback',
+        error: 'updateFinalizeErrorCallback'
+      })
+    }
+    else {
+      this.set('isFinalizeItem', false);
+    }
+  }.observes('App.upgradeState'),
+
+  /**
+   *
+   * @param {object|null} data
+   * @method updateFinalizeSuccessCallback
+   */
+  updateFinalizeSuccessCallback: function (data) {
+    var context = data ? Em.get(data, 'upgrade_groups.firstObject.upgrade_items.firstObject.UpgradeItem.context')
: '';
+    this.set('isFinalizeItem', context === this.get('finalizeContext'));
+  },
+
+  updateFinalizeErrorCallback: function() {
+    this.set('isFinalizeItem', false);
+  },
+
+  /**
    * show dialog with tasks of upgrade
    * @return {App.ModalPopup}
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/5d159a37/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 53156d0..3b613e7 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -1407,6 +1407,7 @@ Em.I18n.translations = {
   'admin.stackVersions.version.reinstall': "Reinstall Packages",
   'admin.stackVersions.version.performUpgrade': "Perform Upgrade",
   'admin.stackVersions.version.upgrade.pause': "Upgrade: Action Required",
+  'admin.stackVersions.version.upgrade.notFinalized.warning': "The upgrade has not been finalized
yet. After the cluster is verified to be functional, do not forget to finalize the upgrade
as soon as possible (within a couple of days is highly recommended) as running the cluster
in unfinalized state causes extra resource requirements on HDFS.",
   'admin.stackVersions.version.upgrade.running': "Upgrade: In Process",
   'admin.stackVersions.version.upgrade.aborted': "Upgrade: Aborted",
   'admin.stackVersions.version.downgrade.pause': "Downgrade: Action Required",

http://git-wip-us.apache.org/repos/asf/ambari/blob/5d159a37/ambari-web/app/styles/application.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/application.less b/ambari-web/app/styles/application.less
index ac8896f..d9ec7d7 100644
--- a/ambari-web/app/styles/application.less
+++ b/ambari-web/app/styles/application.less
@@ -2040,7 +2040,7 @@ a:focus {
     font-size: 11px;
   }
   .upgrade-status-warning {
-    color: @health-status-orange;
+    color: @health-status-red;
   }
   tr td:first-child {
     width: 180px;

http://git-wip-us.apache.org/repos/asf/ambari/blob/5d159a37/ambari-web/app/templates/application.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/application.hbs b/ambari-web/app/templates/application.hbs
index eda5fa5..28a36cb 100644
--- a/ambari-web/app/templates/application.hbs
+++ b/ambari-web/app/templates/application.hbs
@@ -102,8 +102,9 @@
       {{#if App.upgradeIsNotFinished}}
         <div class="ru-badge span12">
           <div class="navbar navbar-static-top clearfix">
-            <div class="span4 offset4">
+            <div class="span11">
               {{#if isExistingClusterDataLoaded}}
+                <p class="span4 offset4">
                 <a class="brand cluster-name" href="#">
                   {{#if App.upgradeInProgress}}
                     {{#if App.router.mainAdminStackAndUpgradeController.isDowngrade}}
@@ -139,6 +140,10 @@
                     {{/if}}
                   {{/if}}
                 </a>
+                </p>
+                {{#if App.router.mainAdminStackAndUpgradeController.isFinalizeItem}}
+                  <p class="span10 alert alert-warning">{{t admin.stackVersions.version.upgrade.notFinalized.warning}}</p>
+                {{/if}}
               {{/if}}
             </div>
           </div>

http://git-wip-us.apache.org/repos/asf/ambari/blob/5d159a37/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 888cdf4..b1542c9 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -1501,6 +1501,10 @@ var urls = {
     'real': '/clusters/{clusterName}/upgrades/{id}?fields=Upgrade',
     'mock': '/data/stack_versions/upgrade.json'
   },
+  'admin.upgrade.finalizeContext': {
+    'real': '/clusters/{clusterName}/upgrades/{id}?upgrade_groups/upgrade_items/UpgradeItem/status=HOLDING&fields=upgrade_groups/upgrade_items/UpgradeItem/context',
+    'mock': '/data/stack_versions/upgrade.json'
+  },
   'admin.upgrade.upgrade_item': {
     'real': '/clusters/{clusterName}/upgrades/{upgradeId}/upgrade_groups/{groupId}/upgrade_items/{stageId}?fields='
+
     'UpgradeItem/group_id,' +

http://git-wip-us.apache.org/repos/asf/ambari/blob/5d159a37/ambari-web/app/views/main/admin/stack_upgrade/upgrade_wizard_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_wizard_view.js b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_wizard_view.js
index d7098a6..fde7906 100644
--- a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_wizard_view.js
+++ b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_wizard_view.js
@@ -174,7 +174,7 @@ App.upgradeWizardView = Em.View.extend({
    * @type {boolean}
    */
   isFinalizeItem: function () {
-    return this.get('manualItem.context') === 'Confirm Finalize';
+    return this.get('manualItem.context') === this.get('controller.finalizeContext');
   }.property('manualItem.context'),
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/5d159a37/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 73327f5..253ef80 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
@@ -274,7 +274,6 @@ describe('App.MainAdminStackAndUpgradeController', function() {
     });
   });
 
-
   describe("#runPreUpgradeCheck()", function() {
     before(function () {
       sinon.stub(App.ajax, 'send', Em.K);
@@ -1122,4 +1121,94 @@ describe('App.MainAdminStackAndUpgradeController', function() {
     });
 
   });
+
+  describe('#updateFinalize', function () {
+
+    beforeEach(function() {
+      sinon.stub($, 'ajax', Em.K);
+      controller.set('isFinalizeItem', true);
+    });
+
+    afterEach(function () {
+      $.ajax.restore();
+    });
+
+    it('should do ajax-request', function () {
+      sinon.stub(App, 'get').withArgs('upgradeState').returns('HOLDING');
+      controller.updateFinalize();
+      App.get.restore();
+      expect($.ajax.calledOnce).to.be.true;
+    });
+
+    it('shouldn\'t do ajax-request', function () {
+      sinon.stub(App, 'get').withArgs('upgradeState').returns('HOLDING_TIMEDOUT');
+      controller.updateFinalize();
+      App.get.restore();
+      expect(controller.get('isFinalizeItem')).to.be.false;
+      expect($.ajax.calledOnce).to.be.false;
+    });
+
+  });
+
+  describe('#updateFinalizeSuccessCallback', function () {
+
+    it('data exists and Finalize should be true', function() {
+      var data = {
+        upgrade_groups: [
+          {
+            upgrade_items: [
+              {
+                UpgradeItem: {
+                  context: controller.get('finalizeContext'),
+                  status: "HOLDING"
+                }
+              }
+            ]
+          }
+        ]
+      };
+      controller.set('isFinalizeItem', false);
+      controller.updateFinalizeSuccessCallback(data);
+      expect(controller.get('isFinalizeItem')).to.be.true;
+    });
+
+    it('data exists and Finalize should be false', function() {
+      var data = {
+        upgrade_groups: [
+          {
+            upgrade_items: [
+              {
+                UpgradeItem: {
+                  context: '!@#$%^&',
+                  status: "HOLDING"
+                }
+              }
+            ]
+          }
+        ]
+      };
+      controller.set('isFinalizeItem', true);
+      controller.updateFinalizeSuccessCallback(data);
+      expect(controller.get('isFinalizeItem')).to.be.false;
+    });
+
+    it('data doesn\'t exist', function() {
+      var data = null;
+      controller.set('isFinalizeItem', true);
+      controller.updateFinalizeSuccessCallback(data);
+      expect(controller.get('isFinalizeItem')).to.be.false;
+    });
+
+  });
+
+  describe('#updateFinalizeErrorCallback', function () {
+
+    it('should set isFinalizeItem to false', function () {
+      controller.set('isFinalizeItem', true);
+      controller.updateFinalizeErrorCallback();
+      expect(controller.get('isFinalizeItem')).to.be.false;
+    });
+
+  });
+
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/5d159a37/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js
index 37027b1..b762500 100644
--- a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js
+++ b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js
@@ -26,6 +26,7 @@ describe('App.upgradeWizardView', function () {
   });
   view.reopen({
     controller: Em.Object.create({
+      finalizeContext: 'Confirm Finalize',
       upgradeData: Em.Object.create(),
       loadUpgradeData: Em.K,
       setUpgradeItemStatus: Em.K,
@@ -422,7 +423,7 @@ describe('App.upgradeWizardView', function () {
   });
 
   describe("#isFinalizeItem", function () {
-    it("", function () {
+    it("depends of manualItem.context", function () {
       view.reopen({
         manualItem: {
           context: 'Confirm Finalize'


Mime
View raw message