Browse Source

AMBARI-8457 Rolling Upgrade process: upgrade progress popup. (atkach)

Andrii Tkach 10 years ago
parent
commit
ee9abd1b10

+ 70 - 0
ambari-web/app/assets/data/stack_versions/upgrade.json

@@ -0,0 +1,70 @@
+{
+  "items": [
+    {
+      "UpgradeItem": {
+        "upgrade_item_id": 1,
+        "step_index": 1,
+        "status": "COMPLETED",
+        "stage_id": 124321,
+        "command": "Restart Zookeeper Server on host1",
+        "type": "auto",
+        "description": ""
+      }
+    },
+    {
+      "UpgradeItem": {
+        "upgrade_item_id": 2,
+        "step_index": 2,
+        "status": "WARNING",
+        "stage_id": 124321,
+        "command": "Restart Zookeeper Server on host2",
+        "type": "auto",
+        "description": ""
+      }
+    },
+    {
+      "UpgradeItem": {
+        "upgrade_item_id": 3,
+        "step_index": 3,
+        "status": "IN_PROGRESS",
+        "stage_id": 124321,
+        "command": "Run manual steps",
+        "type": "manual",
+        "description": "List of manual steps"
+      }
+    },
+    {
+      "UpgradeItem": {
+        "upgrade_item_id": 4,
+        "step_index": 4,
+        "status": "PENDING",
+        "stage_id": 124321,
+        "command": "Restart Datanode on 2 hosts",
+        "type": "auto",
+        "description": ""
+      }
+    },
+    {
+      "UpgradeItem": {
+        "upgrade_item_id": 5,
+        "step_index": 5,
+        "status": "PENDING",
+        "stage_id": 124321,
+        "command": "Restart Datanode on 2 hosts",
+        "type": "auto",
+        "description": ""
+      }
+    },
+    {
+      "UpgradeItem": {
+        "upgrade_item_id": 6,
+        "step_index": 6,
+        "status": "FAILED",
+        "stage_id": 124321,
+        "command": "Restart Zookeeper Server on host3",
+        "type": "auto",
+        "description": ""
+      }
+    }
+  ]
+}

+ 2 - 1
ambari-web/app/assets/test/tests.js

@@ -160,7 +160,8 @@ var files = ['test/init_model_test',
   'test/views/main/alerts/manage_alert_groups_view_test',
   'test/views/main/alerts/manage_alert_notifications_view_test',
   'test/views/main/admin/stack_version/stack_version_details_test',
-  'test/views/main/admin/upgrade_version_box_view_test',
+  'test/views/main/admin/stack_upgrade/upgrade_version_box_view_test',
+  'test/views/main/admin/stack_upgrade/upgrade_task_view_test',
   'test/views/main/dashboard/config_history_view_test',
   'test/views/main/dashboard/widget_test',
   'test/views/main/dashboard/widgets_test',

+ 51 - 0
ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js

@@ -22,6 +22,7 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend({
   name: 'mainAdminStackAndUpgradeController',
 
   serviceToInstall: null,
+  upgradeTasks: [],
 
   /**
    * version that currently applied to server
@@ -77,6 +78,33 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend({
     }));
   },
 
+  /**
+   * load upgrade tasks by upgrade id
+   * @return {$.ajax}
+   */
+  loadUpgradeTasks: function () {
+    //TODO should make call with actual upgrade id
+    var upgradeId = 1;
+    return App.ajax.send({
+      name: 'admin.upgrade.tasks',
+      sender: this,
+      data: {
+        id: upgradeId
+      },
+      success: 'loadUpgradeTasksSuccessCallback'
+    });
+  },
+
+  /**
+   * parse and push upgrade tasks to controller
+   * @param data
+   */
+  loadUpgradeTasksSuccessCallback: function (data) {
+    this.set("upgradeTasks", data.items.map(function (item) {
+      return item.UpgradeItem;
+    }));
+  },
+
   /**
    * start cluster downgrade
    */
@@ -88,6 +116,8 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend({
    */
   upgrade: function () {
     //TODO start actual upgrade
+    this.loadUpgradeTasks();
+    this.openUpgradeDialog();
   },
   /**
    * resume upgrade process
@@ -100,5 +130,26 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend({
    */
   finalize: function () {
     //TODO start actual finalize
+  },
+
+  /**
+   * show dialog with tasks of upgrade
+   * @return {App.ModalPopup}
+   */
+  openUpgradeDialog: function () {
+    var upgradeVersion = 'HDP-2.2.1';
+
+    return App.ModalPopup.show({
+      header: Em.I18n.t('admin.stackUpgrade.dialog.header').format(upgradeVersion),
+      bodyClass: Em.View.extend({
+        controller: this,
+        templateName: require('templates/main/admin/stack_upgrade/stack_upgrade_dialog'),
+        tasks: function () {
+          return this.get('controller.upgradeTasks');
+        }.property('controller.upgradeTasks')
+      }),
+      primary: null,
+      secondary: null
+    });
   }
 });

+ 6 - 0
ambari-web/app/messages.js

@@ -1264,6 +1264,12 @@ Em.I18n.translations = {
   'admin.stackUpgrade.state.finalize': "Finalize",
   'admin.stackUpgrade.hosts': "hosts",
   'admin.stackUpgrade.host': "host",
+  'admin.stackUpgrade.dialog.header': "Upgrade to {0} in progress",
+  'admin.stackUpgrade.dialog.operationFailed': "This operation failed.",
+  'admin.stackUpgrade.dialog.errorLink': "See error message",
+  'admin.stackUpgrade.dialog.stop': "Stop Upgrade",
+  'admin.stackUpgrade.dialog.continue': "Ignore and Continue",
+  'admin.stackUpgrade.dialog.manualDone': "I have preformed the manual steps above.",
 
   'services.service.start':'Start',
   'services.service.stop':'Stop',

+ 26 - 0
ambari-web/app/styles/application.less

@@ -6547,6 +6547,32 @@ i.icon-asterisks {
   }
 }
 
+#stack-upgrade-dialog {
+  .task-list {
+    overflow: auto;
+    .task-details {
+      padding: 2px 4px;
+      margin-left: 15px;
+      .button-row {
+        text-align: right;
+        padding: 5px;
+      }
+      input[type="checkbox"] {
+        margin: 0;
+      }
+      .message {
+        line-height: 30px;
+      }
+    }
+  }
+  .task-list>div {
+    padding: 5px;
+    i {
+      margin-right: 5px;
+    }
+  }
+}
+
 #config-group-select-create-dialog {
   .select-create-config-group-div {
     margin-left: 20px;

+ 38 - 0
ambari-web/app/templates/main/admin/stack_upgrade/stack_upgrade_dialog.hbs

@@ -0,0 +1,38 @@
+{{!
+* 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="stack-upgrade-dialog">
+
+  <div class="row-fluid">
+    <div class="span2">{{t common.progress}}</div>
+    <div class="span9">
+      <div class="progress progress-striped active">
+        <div class="bar" style="width: 40%;"></div>
+      </div>
+    </div>
+    <div class="span1">
+      40%
+    </div>
+  </div>
+
+  <div class="task-list">
+    {{#each task in view.tasks}}
+      {{view App.upgradeTaskView contentBinding="task"}}
+    {{/each}}
+  </div>
+</div>

+ 48 - 0
ambari-web/app/templates/main/admin/stack_upgrade/upgrade_task.hbs

@@ -0,0 +1,48 @@
+{{!
+* 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.
+}}
+
+<i {{bindAttr class="view.iconClass"}}></i><span>{{view.content.command}}</span>
+{{#if view.isFailed}}
+  <div class="box task-details">
+    <div>
+      {{t admin.stackUpgrade.dialog.operationFailed}}&nbsp;
+      <a href>{{t admin.stackUpgrade.dialog.errorLink}}</a>
+    </div>
+    <div class="button-row">
+      <button class="btn">{{t admin.stackUpgrade.dialog.continue}}</button>
+      <button class="btn btn-danger">{{t admin.stackUpgrade.dialog.stop}}</button>
+      <button class="btn btn-primary">{{t common.retry}}</button>
+    </div>
+  </div>
+{{/if}}
+{{#if view.isManualOpened}}
+  <div class="task-details">
+    <div class="alert alert-info">
+      {{view.content.description}}
+    </div>
+    <div class="row-fluid">
+      <div class="span10 message">
+        {{view Em.Checkbox valueBinding="view.isManualDone"}}
+        {{t admin.stackUpgrade.dialog.manualDone}}
+      </div>
+      <div class="span2">
+        <button class="btn btn-success pull-right">{{t common.proceed}}</button>
+      </div>
+    </div>
+  </div>
+{{/if}}

+ 4 - 0
ambari-web/app/utils/ajax/ajax.js

@@ -1267,6 +1267,10 @@ var urls = {
     'real': '/clusters/{cluster}/requests/{requestId}?fields=tasks/*',
     'mock': '/data/wizard/{mock}'
   },
+  'admin.upgrade.tasks': {
+    'real': '/clusters/{clusterName}/upgrades/{id}/upgrade_items',
+    'mock': '/data/stack_versions/upgrade.json'
+  },
   'admin.stack_versions.all': {
     'real': '/clusters/{clusterName}/stack_versions?fields=ClusterStackVersions/*&minimal_response=true',
     'mock': '/data/stack_versions/stack_version_all.json'

+ 2 - 1
ambari-web/app/views.js

@@ -104,7 +104,8 @@ require('views/main/admin/highAvailability/resourceManager/step3_view');
 require('views/main/admin/highAvailability/resourceManager/step4_view');
 require('views/main/admin/serviceAccounts_view');
 require('views/main/admin/stack_upgrade');
-require('views/main/admin/upgrade_version_box_view');
+require('views/main/admin/stack_upgrade/upgrade_version_box_view');
+require('views/main/admin/stack_upgrade/upgrade_task_view');
 require('views/main/admin/stack_and_upgrade_view');
 require('views/main/admin/stack_versions/stack_version_view');
 require('views/main/admin/stack_versions/stack_version_details_view');

+ 63 - 0
ambari-web/app/views/main/admin/stack_upgrade/upgrade_task_view.js

@@ -0,0 +1,63 @@
+/**
+ * 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.
+ */
+
+
+var App = require('app');
+
+App.upgradeTaskView = Em.View.extend({
+  templateName: require('templates/main/admin/stack_upgrade/upgrade_task'),
+
+  /**
+   * @type {object|null}
+   */
+  task: null,
+
+  statusIconMap: {
+    'COMPLETED': 'icon-ok',
+    'WARNING': 'icon-warning-sign',
+    'FAILED': 'icon-warning-sign',
+    'PENDING': 'icon-cog'
+  },
+
+  /**
+   * @type {boolean}
+   */
+  isManualDone: false,
+
+  /**
+   * @type {string}
+   */
+  iconClass: function () {
+    return this.get('statusIconMap')[this.get('content.status')] || 'icon-question-sign';
+  }.property('content.status'),
+
+  /**
+   * @type {boolean}
+   */
+  isFailed: function () {
+    return this.get('content.status') === 'FAILED';
+  }.property('content.status'),
+
+  /**
+   * @type {boolean}
+   */
+  isManualOpened: function () {
+    //TODO modify logic according to actual API
+    return this.get('content.status') === 'IN_PROGRESS' && this.get('content.type') === 'manual'
+  }.property('content.status', 'content.type')
+});

+ 18 - 1
ambari-web/app/views/main/admin/upgrade_version_box_view.js → ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js

@@ -20,12 +20,29 @@
 var App = require('app');
 
 App.UpgradeVersionBoxView = Em.View.extend({
+  /**
+   * @type {object|null}
+   */
   version: null,
+
+  /**
+   * @type {string}
+   */
   versionName: function () {
+    if (Em.isNone(this.get('version'))) return "";
     return this.get('version.stack') + "-" + this.get('version.version');
   }.property('version.stack', 'version.version'),
+
+  /**
+   * @type {string}
+   */
   btnClass: 'btn-default',
-  hostsCount: null,
+
+  /**
+   * @type {number}
+   */
+  hostsCount: 0,
+
   /**
    * run action by name of method
    * @param event

+ 51 - 0
ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js

@@ -105,4 +105,55 @@ describe('App.MainAdminStackAndUpgradeController', function() {
       }]);
     });
   });
+
+  describe("#loadUpgradeTasks()", function() {
+    before(function () {
+      sinon.stub(App.ajax, 'send', Em.K);
+    });
+    after(function () {
+      App.ajax.send.restore();
+    });
+    it("make ajax call", function() {
+      controller.loadUpgradeTasks();
+      expect(App.ajax.send.getCall(0).args[0]).to.eql({
+        name: 'admin.upgrade.tasks',
+        sender: controller,
+        data: {
+          id: 1
+        },
+        success: 'loadUpgradeTasksSuccessCallback'
+      })
+    });
+  });
+
+  describe("#loadUpgradeTasksSuccessCallback()", function() {
+    it("", function() {
+      var data = {"items": [
+        {
+          "UpgradeItem": {
+            "id": 1
+          }
+        }
+      ]};
+      controller.loadUpgradeTasksSuccessCallback(data);
+      expect(controller.get('upgradeTasks')).to.eql([
+        {
+          "id": 1
+        }
+      ]);
+    });
+  });
+
+  describe("#openUpgradeDialog()", function () {
+    before(function () {
+      sinon.stub(App.ModalPopup, 'show', Em.K);
+    });
+    after(function () {
+      App.ModalPopup.show.restore();
+    });
+    it("should open dialog", function () {
+      controller.openUpgradeDialog();
+      expect(App.ModalPopup.show.calledOnce).to.be.true;
+    });
+  });
 });

+ 59 - 0
ambari-web/test/views/main/admin/stack_upgrade/upgrade_task_view_test.js

@@ -0,0 +1,59 @@
+/**
+ * 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.
+ */
+
+
+var App = require('app');
+require('views/main/admin/stack_upgrade/upgrade_task_view');
+
+describe('App.upgradeTaskView', function () {
+  var view = App.upgradeTaskView.create({
+    content: Em.Object.create()
+  });
+
+  describe("#iconClass", function () {
+    it("status has icon", function () {
+      view.set('statusIconMap', {
+        'S1': 'icon1'
+      });
+      view.set('content.status', 'S1');
+      view.propertyDidChange('iconClass');
+      expect(view.get('iconClass')).to.equal('icon1');
+    });
+    it("status undefined", function () {
+      view.set('statusIconMap', {
+        'S1': 'icon1'
+      });
+      view.set('content.status', 'S2');
+      view.propertyDidChange('iconClass');
+      expect(view.get('iconClass')).to.equal('icon-question-sign');
+    });
+  });
+
+  describe("#isFailed", function () {
+    it("task is not failed", function () {
+      view.set('content.status', 'COMPLETED');
+      view.propertyDidChange('isFailed');
+      expect(view.get('isFailed')).to.be.false;
+    });
+    it("task is not failed", function () {
+      view.set('content.status', 'FAILED');
+      view.propertyDidChange('isFailed');
+      expect(view.get('isFailed')).to.be.true;
+    });
+  });
+});

+ 7 - 2
ambari-web/test/views/main/admin/upgrade_version_box_view_test.js → ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js

@@ -18,7 +18,7 @@
 
 
 var App = require('app');
-require('views/main/admin/upgrade_version_box_view');
+require('views/main/admin/stack_upgrade/upgrade_version_box_view');
 
 describe('App.UpgradeVersionBoxView', function () {
   var view = App.UpgradeVersionBoxView.create({
@@ -28,7 +28,12 @@ describe('App.UpgradeVersionBoxView', function () {
   });
 
   describe("#versionName", function () {
-    it("", function () {
+    it("version is null", function () {
+      view.set('version', null);
+      view.propertyDidChange('versionName');
+      expect(view.get('versionName')).to.be.empty;
+    });
+    it("version is loaded", function () {
       view.set('version', Em.Object.create({
         stack: 'HDP',
         version: '2.2'