Browse Source

AMBARI-5992 Usability: add hostname resolution validation to Host Checks UI. (ababiichuk)

aBabiichuk 11 năm trước cách đây
mục cha
commit
ad1ce50978

+ 89 - 0
ambari-web/app/assets/data/requests/host_check/1.json

@@ -0,0 +1,89 @@
+{
+  "tasks": [
+    {
+      "href": "http://192.168.56.101:8080/api/v1/requests/58/tasks/116",
+      "Tasks": {
+        "attempt_cnt": 0,
+        "command": "ACTIONEXECUTE",
+        "command_detail": "check_host ACTIONEXECUTE",
+        "end_time": -1,
+        "exit_code": 999,
+        "host_name": "dev01.hortonworks.com",
+        "id": 116,
+        "request_id": 58,
+        "role": "check_host",
+        "stage_id": 1,
+        "start_time": -1,
+        "status": "COMPLETED",
+        "stderr": "",
+        "stdout": "",
+        "structured_out": {
+          "host_resolution_check": {
+            "failures": [
+              {
+                "type": "FORWARD_LOOKUP",
+                "host": "foobar",
+                "cause": [-3, "Temporary failure in name resolution"]
+              },
+              {
+                "type": "FORWARD_LOOKUP",
+                "host": "!!!",
+                "cause": [-3, "Temporary failure in name resolution"]
+              }
+            ],
+            "failed_count": 2,
+            "success_count": 3,
+            "exit_code": "0",
+            "message": "There were 2 host(s) that could not resolve to an IP address."
+          }
+        }
+      }
+    },
+    {
+      "href": "http://192.168.56.101:8080/api/v1/requests/58/tasks/117",
+      "Tasks": {
+        "attempt_cnt": 0,
+        "command": "ACTIONEXECUTE",
+        "command_detail": "check_host ACTIONEXECUTE",
+        "end_time": -1,
+        "exit_code": 999,
+        "host_name": "dev02.hortonworks.com",
+        "id": 116,
+        "request_id": 58,
+        "role": "check_host",
+        "stage_id": 1,
+        "start_time": -1,
+        "status": "COMPLETED",
+        "stderr": "",
+        "stdout": "",
+        "structured_out": {
+          "host_resolution_check": {
+            "failed_count": "0",
+            "failures": [],
+            "success_count": "5"
+          }
+        }
+      }
+    },
+    {
+      "href": "http://192.168.56.101:8080/api/v1/requests/58/tasks/118",
+      "Tasks": {
+        "attempt_cnt": 0,
+        "command": "ACTIONEXECUTE",
+        "command_detail": "check_host ACTIONEXECUTE",
+        "end_time": -1,
+        "exit_code": 999,
+        "host_name": "dev03.hortonworks.com",
+        "id": 116,
+        "request_id": 58,
+        "role": "check_host",
+        "stage_id": 1,
+        "start_time": -1,
+        "status": "FAILED",
+        "stderr": "",
+        "stdout": "",
+        "structured_out": ""
+      }
+    }
+  ]
+}

+ 130 - 3
ambari-web/app/controllers/wizard/step3_controller.js

@@ -38,6 +38,9 @@ App.WizardStep3Controller = Em.Controller.extend({
 
   registrationStartedAt: null,
 
+  requestId: 0,
+
+  hostCheckWarnings: [],
   /**
    * Timeout for registration
    * Based on <code>installOptions.manualInstall</code>
@@ -161,7 +164,7 @@ App.WizardStep3Controller = Em.Controller.extend({
       } else {
         this.set('bootHosts', this.get('hosts'));
         if (App.get('testMode')) {
-          this.getHostInfo();
+          this.startHostcheck();
           this.get('bootHosts').setEach('cpu', '2');
           this.get('bootHosts').setEach('memory', '2000000');
           this.set('isSubmitDisabled', false);
@@ -594,7 +597,7 @@ App.WizardStep3Controller = Em.Controller.extend({
     }, this);
 
     if (stopPolling) {
-      this.getHostInfo();
+      this.startHostcheck();
     }
     else {
       if (hosts.someProperty('bootStatus', 'RUNNING') || App.dateTime() - this.get('registrationStartedAt') < this.get('registrationTimeoutSecs') * 1000) {
@@ -611,7 +614,7 @@ App.WizardStep3Controller = Em.Controller.extend({
           _host.set('bootStatus', 'FAILED');
           _host.set('bootLog', (_host.get('bootLog') != null ? _host.get('bootLog') : '') + Em.I18n.t('installer.step3.hosts.bootLog.failed'));
         });
-        this.getHostInfo();
+        this.startHostcheck();
       }
     }
   },
@@ -685,6 +688,130 @@ App.WizardStep3Controller = Em.Controller.extend({
     });
   },
 
+  
+  startHostcheck: function() {
+    this.set('isWarningsLoaded', false);
+    this.getHostNameResolution();   
+  },
+
+  getHostNameResolution: function () {
+    var hosts = this.get('bootHosts').getEach('name').join(",");
+    var RequestInfo = {
+      "action": "check_host",
+      "context": "Check host",
+      "parameters": {
+        "check_execute_list": "host_resolution_check",
+        "hosts": hosts,
+        "threshold": "20"
+      }
+    };
+    var resource_filters = {
+      "hosts": hosts
+    };
+    if (App.testMode) {
+      this.getHostNameResolutionSuccess();
+    } else {
+      return App.ajax.send({
+        name: 'preinstalled.checks',
+        sender: this,
+        data: {
+          RequestInfo: RequestInfo,
+          resource_filters: resource_filters
+        },
+        success: 'getHostNameResolutionSuccess',
+        error: 'getHostNameResolutionError'
+      });
+    }
+  },
+
+  getHostNameResolutionSuccess: function(response) {
+    if (!App.testMode) {
+      this.set("requestId", response.Requests.id);
+    }
+    this.getHostCheckTasks();
+  },
+
+  getHostNameResolutionError: function() {
+    this.getHostInfo();
+  },
+
+  /**
+   * send ajax request to get all tasks
+   * @method getHostCheckTasks
+   */
+  getHostCheckTasks: function () {
+    var requestId = this.get("requestId");
+    var self = this;
+    this.set('startChecking', new Date().getTime());
+    var checker = setInterval(function () {
+      if (self.get('stopChecking') == true) {
+        clearInterval(checker);
+        self.getHostInfo();
+      } else {
+        App.ajax.send({
+          name: 'preinstalled.checks.tasks',
+          sender: self,
+          data: {
+            requestId: requestId
+          },
+          success: 'getHostCheckTasksSuccess',
+          error: 'getHostCheckTasksError'
+        });
+      }
+    }, 1000);
+  },
+
+  /**
+   * add warnings to host warning popup if needed
+   * @param data {Object} - json
+   * @method getHostCheckTasksSuccess
+   */
+  getHostCheckTasksSuccess: function (data) {
+    console.log('checking attempt...');
+    if (!data) {
+      console.warn("Error: jsonData is null");
+      return;
+    }
+    this.set('stopChecking', true);
+    data.tasks.forEach(function (task) {
+      var cur = new Date().getTime();
+      var name = Em.I18n.t('installer.step3.hostWarningsPopup.resolution.validation.error');
+      var hostInfo = this.get("hostCheckWarnings").findProperty('name', name);
+      if (task.Tasks.status == "FAILED" || (cur - this.get('startChecking') > 5000) || task.Tasks.status == "COMPLETED") {
+        if (task.Tasks.status == "COMPLETED" && Em.get(task, 'Tasks.structured_out.host_resolution_check.failed_count') == 0) {
+          return;
+        }
+        if (!hostInfo) {
+          hostInfo = {
+            name: name,
+            hosts: [task.Tasks.host_name],
+            onSingleHost: true
+          };
+          this.get("hostCheckWarnings").push(hostInfo);
+        } else {
+          hostInfo.hosts.push(task.Tasks.host_name);
+        }
+      } else {
+        this.set('stopChecking', false);
+      }
+    }, this);
+  },
+
+  stopChecking: false,
+
+  /**
+   * startChecking {Number} - timestamp
+   */
+  startChecking: 0,
+
+  /**
+   * @method getHostCheckTasksError
+   */
+  getHostCheckTasksError: function() {
+    console.warn("failed to cheek hostName resolution");
+    this.set('stopChecking', true);
+  },
+
   /**
    * Success-callback for hosts info request
    * @param {object} jsonData

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

@@ -509,9 +509,14 @@ Em.I18n.translations = {
   'installer.step3.hostWarningsPopup.empty.repositories':'repositories OS type mis-match with registered hosts',
   'installer.step3.hostWarningsPopup.empty.disk':'disk space issues',
   'installer.step3.hostWarningsPopup.reverseLookup.name': 'Reverse Lookup validation failed on',
-  'installer.step3.hostWarningsPopup.reverseLookup': 'Reverse Lookup issues',
+  'installer.step3.hostWarningsPopup.reverseLookup': 'Reverse Lookup Issues',
   'installer.step3.hostWarningsPopup.reverseLookup.message': 'The hostname was not found in the reverse DNS lookup. This may result in incorrect behavior. Please check the DNS setup and fix the issue.',
   'installer.step3.hostWarningsPopup.reverseLookup.empty': 'reverse DNS lookup issues.',
+  'installer.step3.hostWarningsPopup.resolution.validation.name': 'Hostname Resolution Issues',
+  'installer.step3.hostWarningsPopup.resolution.validation.error': 'Hostname resolution failed on',
+  'installer.step3.hostWarningsPopup.resolution.validation': 'Hostname resolution validation',
+  'installer.step3.hostWarningsPopup.resolution.validation.message': 'Not all hosts could resolve hostnames of other hosts. Make sure that host resolution works properly on all hosts before continuing.',
+  'installer.step3.hostWarningsPopup.resolution.validation.empty': 'hostname resolution issues',
   'installer.step3.hostWarningsPopup.action.exists':'Exists on',
   'installer.step3.hostWarningsPopup.action.notRunning':'Not running on',
   'installer.step3.hostWarningsPopup.action.installed':'Installed on',

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

@@ -1601,6 +1601,26 @@ var urls = {
       };
     }
   },
+
+  'preinstalled.checks': {
+    'real':'/requests',
+    'mock':'',
+    'format': function(data) {
+      return {
+        type : 'POST',
+        data : JSON.stringify({
+          "RequestInfo": data.RequestInfo,
+          "Requests/resource_filters": [data.resource_filters]
+        })
+      }
+    }
+  },
+
+  'preinstalled.checks.tasks': {
+    'real':'/requests/{requestId}?fields=tasks/Tasks',
+    'mock':'/data/requests/host_check/1.json'
+  },
+
   'wizard.step3.rerun_checks': {
     'real': '/hosts?fields=Hosts/last_agent_env',
     'mock': '/data/wizard/bootstrap/two_hosts_information.json',

+ 9 - 0
ambari-web/app/views/wizard/step3/hostWarningPopupBody_view.js

@@ -144,6 +144,7 @@ App.WizardStep3HostWarningPopupBody = Em.View.extend({
   content: function () {
     var repoCategoryWarnings = this.get('bodyController.repoCategoryWarnings');
     var diskCategoryWarnings = this.get('bodyController.diskCategoryWarnings');
+    var hostCheckWarnings = this.get('bodyController.hostCheckWarnings');
     var categoryWarnings = this.get('categoryWarnings');
     return [
       Em.Object.create({
@@ -253,6 +254,14 @@ App.WizardStep3HostWarningPopupBody = Em.View.extend({
         emptyName: Em.I18n.t('installer.step3.hostWarningsPopup.reverseLookup.empty'),
         category: 'reverseLookup',
         isCollapsed: true
+      }),
+      Em.Object.create({
+        warnings: hostCheckWarnings,
+        title: Em.I18n.t('installer.step3.hostWarningsPopup.resolution.validation.name'),
+        message: Em.I18n.t('installer.step3.hostWarningsPopup.resolution.validation.message'),
+        emptyName: Em.I18n.t('installer.step3.hostWarningsPopup.resolution.validation.empty'),
+        category: 'hostNameResolution',
+        isCollapsed: true
       })
     ]
   }.property('category', 'warningsByHost'),

+ 2 - 2
ambari-web/test/controllers/wizard/step3_test.js

@@ -698,7 +698,7 @@ describe('App.WizardStep3Controller', function () {
         m: ' one host REGISTERING',
         e: {
           bs: 'FAILED',
-          getHostInfoCalled: true
+          getHostInfoCalled: false
         }
       },
       {
@@ -709,7 +709,7 @@ describe('App.WizardStep3Controller', function () {
         m: 'one host REGISTERING but data without info about it',
         e: {
           bs: 'FAILED',
-          getHostInfoCalled: true
+          getHostInfoCalled: false
         }
       },
       {