ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From srima...@apache.org
Subject ambari git commit: AMBARI-12927. Robustness of Stack Advisor to handle missing configs and others. (srimanth)
Date Mon, 31 Aug 2015 20:53:56 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk f3f7e09aa -> 6cc7781bb


AMBARI-12927. Robustness of Stack Advisor to handle missing configs and others. (srimanth)


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

Branch: refs/heads/trunk
Commit: 6cc7781bb6722021252252f0589040bfc3f6dedd
Parents: f3f7e09
Author: Srimanth Gunturi <sgunturi@hortonworks.com>
Authored: Sat Aug 29 01:19:49 2015 -0700
Committer: Srimanth Gunturi <sgunturi@hortonworks.com>
Committed: Mon Aug 31 13:53:50 2015 -0700

----------------------------------------------------------------------
 .../src/main/resources/scripts/stack_advisor.py | 16 ++++++-----
 .../stacks/HDP/2.0.6/services/stack_advisor.py  | 16 ++---------
 .../src/main/resources/stacks/stack_advisor.py  |  7 +----
 .../stacks/2.3/common/test_stack_advisor.py     | 14 +++++-----
 .../app/controllers/wizard/step6_controller.js  |  3 +--
 ambari-web/app/messages.js                      |  4 +--
 .../mixins/common/configs/enhanced_configs.js   |  3 ++-
 ambari-web/app/mixins/common/serverValidator.js | 28 +++++++++++++++-----
 .../mixins/wizard/assign_master_components.js   |  3 +--
 9 files changed, 47 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/6cc7781b/ambari-server/src/main/resources/scripts/stack_advisor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/scripts/stack_advisor.py b/ambari-server/src/main/resources/scripts/stack_advisor.py
index 446086c..cdd9acb 100755
--- a/ambari-server/src/main/resources/scripts/stack_advisor.py
+++ b/ambari-server/src/main/resources/scripts/stack_advisor.py
@@ -50,16 +50,18 @@ def loadJson(path):
   try:
     with open(path, 'r') as f:
       return json.load(f)
-  except Exception, err:
-    raise StackAdvisorException("File not found at: {0}".format(path))
+  except Exception as err:
+    traceback.print_exc()
+    raise StackAdvisorException("Error loading file at: {0}".format(path))
 
 
 def dumpJson(json_object, dump_file):
   try:
     with open(dump_file, 'w') as out:
       json.dump(json_object, out, indent=1)
-  except Exception, err:
-    raise StackAdvisorException("Can not write to file {0} : {1}".format(dump_file, str(err)))
+  except Exception as err:
+    traceback.print_exc()
+    raise StackAdvisorException("Error writing to file {0} : {1}".format(dump_file, str(err)))
 
 
 def main(argv=None):
@@ -137,14 +139,16 @@ def instantiateStackAdvisor(stackName, stackVersion, parentVersions):
         stack_advisor = imp.load_module('stack_advisor_impl', fp, path, ('.py', 'rb', imp.PY_SOURCE))
       className = STACK_ADVISOR_IMPL_CLASS_TEMPLATE.format(stackName, version.replace('.',
''))
       print "StackAdvisor implementation for stack {0}, version {1} was loaded".format(stackName,
version)
-    except Exception:
+    except Exception as e:
+      traceback.print_exc()
       print "StackAdvisor implementation for stack {0}, version {1} was not found".format(stackName,
version)
 
   try:
     clazz = getattr(stack_advisor, className)
     print "Returning " + className + " implementation"
     return clazz()
-  except Exception, e:
+  except Exception as e:
+    traceback.print_exc()
     print "Returning default implementation"
     return default_stack_advisor.DefaultStackAdvisor()
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/6cc7781b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py
index 5fa9f41..f66c855 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/stack_advisor.py
@@ -385,20 +385,8 @@ class HDP206StackAdvisor(DefaultStackAdvisor):
               print("SiteName: %s, method: %s\n" % (siteName, method.__name__))
               print("Site properties: %s\n" % str(siteProperties))
               print("Recommendations: %s\n********\n" % str(siteRecommendations))
-              try:
-                resultItems = method(siteProperties, siteRecommendations, configurations,
services, hosts)
-                items.extend(resultItems)
-              except (AttributeError, TypeError, LookupError) as e:
-                msg = "Failed to validate configuration "
-                print msg
-                print e
-                items.extend([{
-                                'message': msg,
-                                'level': 'ERROR',
-                                'config-type': siteName,
-                                'config-name': '',
-                                'type': 'configuration'
-                              }])
+              resultItems = method(siteProperties, siteRecommendations, configurations, services,
hosts)
+              items.extend(resultItems)
 
     clusterWideItems = self.validateClusterConfigurations(configurations, services, hosts)
     items.extend(clusterWideItems)

http://git-wip-us.apache.org/repos/asf/ambari/blob/6cc7781b/ambari-server/src/main/resources/stacks/stack_advisor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/stack_advisor.py b/ambari-server/src/main/resources/stacks/stack_advisor.py
index 708aaf7..0ef953d 100644
--- a/ambari-server/src/main/resources/stacks/stack_advisor.py
+++ b/ambari-server/src/main/resources/stacks/stack_advisor.py
@@ -566,12 +566,7 @@ class DefaultStackAdvisor(StackAdvisor):
       for service in servicesList:
         calculation = self.getServiceConfigurationRecommender(service)
         if calculation is not None:
-          try:
-            calculation(configurations, clusterSummary, services, hosts)
-          except (AttributeError, TypeError, LookupError) as e:
-            # NOP
-            print "Failed to recommend configuration "
-            print e
+          calculation(configurations, clusterSummary, services, hosts)
 
     return recommendations
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/6cc7781b/ambari-server/src/test/python/stacks/2.3/common/test_stack_advisor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.3/common/test_stack_advisor.py b/ambari-server/src/test/python/stacks/2.3/common/test_stack_advisor.py
index 08c48d8..bea7d60 100644
--- a/ambari-server/src/test/python/stacks/2.3/common/test_stack_advisor.py
+++ b/ambari-server/src/test/python/stacks/2.3/common/test_stack_advisor.py
@@ -803,13 +803,11 @@ class TestHDP23StackAdvisor(TestCase):
       "ranger-hbase-plugin-enabled": "Yes"
     }
 
-    recommendations = self.stackAdvisor.recommendConfigurations(services, hosts)
-
-    for serviceName, validator in validators.items():
-      recommendedDefaults = recommendations["recommendations"]["blueprint"]["configurations"]
-      for siteName, method in validator.items():
-        if siteName in recommendedDefaults:
-          siteRecommendations = recommendedDefaults[siteName]["properties"]
-          method(properties, siteRecommendations, configurations, services, hosts)
+    exceptionThrown = False
+    try:
+      recommendations = self.stackAdvisor.recommendConfigurations(services, hosts)
+    except Exception as e:
+      exceptionThrown = True
+    self.assertTrue(exceptionThrown)
 
     pass

http://git-wip-us.apache.org/repos/asf/ambari/blob/6cc7781b/ambari-web/app/controllers/wizard/step6_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step6_controller.js b/ambari-web/app/controllers/wizard/step6_controller.js
index 204a5fa..83828b5 100644
--- a/ambari-web/app/controllers/wizard/step6_controller.js
+++ b/ambari-web/app/controllers/wizard/step6_controller.js
@@ -706,8 +706,7 @@ App.WizardStep6Controller = Em.Controller.extend(App.BlueprintMixin, {
    * @method updateValidationsErrorCallback
    */
   updateValidationsErrorCallback: function (jqXHR, ajaxOptions, error, opt) {
-    App.ajax.defaultErrorHandler(jqXHR, opt.url, opt.method, jqXHR.status);
-    console.log('Load validations failed');
+    console.error('Config validation failed: ', jqXHR, ajaxOptions, error, opt);
   },
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/6cc7781b/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index ddaf2d8..78f51f8 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -782,9 +782,9 @@ Em.I18n.translations = {
   'installer.step7.popup.mySQLWarning.confirmation.body': 'You will be brought back to the
\"Assign Masters\" step and will lose all your current customizations. Are you sure?',
   'installer.step7.popup.database.connection.header': 'Database Connectivity Warning',
   'installer.step7.popup.database.connection.body': 'You have not run or passed the database
connection test for: {0}. It is highly recommended that you pass the connection test before
proceeding to prevent failures during deployment.',
-  'installer.step7.popup.validation.failed.header': 'Validation failed.',
+  'installer.step7.popup.validation.failed.header': 'Consistency Check Failed',
   'installer.step7.popup.validation.failed.body': 'Some services are not properly configured.
You have to change the highlighted configs according to the recommended values.',
-  'installer.step7.popup.validation.request.failed.body': 'Config validation failed.',
+  'installer.step7.popup.validation.request.failed.body': 'The configuration changes could
not be validated for consistency due to an unknown error.  Your changes have not been saved
yet.  Would you like to proceed and save the changes?',
   'installer.step7.popup.validation.warning.header': 'Configurations',
   'installer.step7.popup.validation.warning.body': 'Some service configurations are not configured
properly. We recommend you review and change the highlighted configuration values. Are you
sure you want to proceed without correcting configurations?',
   'installer.step7.popup.oozie.derby.warning': 'Derby is not recommended for production use.
With Derby, Oozie Server HA and concurrent connection support will not be available.',

http://git-wip-us.apache.org/repos/asf/ambari/blob/6cc7781b/ambari-web/app/mixins/common/configs/enhanced_configs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/configs/enhanced_configs.js b/ambari-web/app/mixins/common/configs/enhanced_configs.js
index 36cf8e6..18f6da6 100644
--- a/ambari-web/app/mixins/common/configs/enhanced_configs.js
+++ b/ambari-web/app/mixins/common/configs/enhanced_configs.js
@@ -390,7 +390,8 @@ App.EnhancedConfigsMixin = Em.Mixin.create({
    */
   dependenciesError: function(jqXHR, ajaxOptions, error, opt) {
     this.set('recommendationTimeStamp', (new Date).getTime());
-    App.ajax.defaultErrorHandler(jqXHR, opt.url, opt.method, jqXHR.status);
+    // We do not want to show user dialogs of failed recommendations
+    console.error("ERROR: Unable to determine recommendations for configs: ", jqXHR, ajaxOptions,
error, opt);
   },
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/6cc7781b/ambari-web/app/mixins/common/serverValidator.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/serverValidator.js b/ambari-web/app/mixins/common/serverValidator.js
index 9d696c2..7b41689 100644
--- a/ambari-web/app/mixins/common/serverValidator.js
+++ b/ambari-web/app/mixins/common/serverValidator.js
@@ -174,8 +174,7 @@ App.ServerValidatorMixin = Em.Mixin.create({
   },
 
   loadRecommendationsError: function(jqXHR, ajaxOptions, error, opt) {
-    App.ajax.defaultErrorHandler(jqXHR, opt.url, opt.method, jqXHR.status);
-    console.error('Load recommendations failed');
+    console.error("ERROR: Unable to determine recommendations for configs: ", jqXHR, ajaxOptions,
error, opt);
   },
 
   serverSideValidation: function () {
@@ -313,8 +312,7 @@ App.ServerValidatorMixin = Em.Mixin.create({
 
   validationError: function (jqXHR, ajaxOptions, error, opt) {
     this.set('configValidationFailed', true);
-    App.ajax.defaultErrorHandler(jqXHR, opt.url, opt.method, jqXHR.status);
-    console.error('config validation failed');
+    console.error('Config validation failed: ', jqXHR, ajaxOptions, error, opt);
   },
 
 
@@ -327,8 +325,26 @@ App.ServerValidatorMixin = Em.Mixin.create({
   warnUser: function(deferred) {
     var self = this;
     if (this.get('configValidationFailed')) {
-      deferred.reject();
-      return App.showAlertPopup(Em.I18n.t('installer.step7.popup.validation.failed.header'),
Em.I18n.t('installer.step7.popup.validation.request.failed.body'));
+      console.error("Config validation failed. Going ahead with saving of configs");
+      return App.ModalPopup.show({
+        header: Em.I18n.t('installer.step7.popup.validation.failed.header'),
+        primary: Em.I18n.t('common.proceedAnyway'),
+        primaryClass: 'btn-danger',
+        marginBottom: 200,
+        onPrimary: function () {
+          this.hide();
+          deferred.resolve();
+        },
+        onSecondary: function () {
+          this.hide();
+          deferred.reject("invalid_configs"); // message used to differentiate types of rejections.
+        },
+        onClose: function () {
+          this.hide();
+          deferred.reject("invalid_configs"); // message used to differentiate types of rejections.
+        },
+        body: Em.I18n.t('installer.step7.popup.validation.request.failed.body')
+      });
     } else if (this.get('configValidationWarning') || this.get('configValidationError'))
{
       // Motivation: for server-side validation warnings and EVEN errors allow user to continue
wizard
       return App.ModalPopup.show({

http://git-wip-us.apache.org/repos/asf/ambari/blob/6cc7781b/ambari-web/app/mixins/wizard/assign_master_components.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/wizard/assign_master_components.js b/ambari-web/app/mixins/wizard/assign_master_components.js
index 1b0be45..1eec8ae 100644
--- a/ambari-web/app/mixins/wizard/assign_master_components.js
+++ b/ambari-web/app/mixins/wizard/assign_master_components.js
@@ -431,8 +431,7 @@ App.AssignMasterComponents = Em.Mixin.create({
    * @method updateValidationsErrorCallback
    */
   updateValidationsErrorCallback: function (jqXHR, ajaxOptions, error, opt) {
-    App.ajax.defaultErrorHandler(jqXHR, opt.url, opt.method, jqXHR.status);
-    console.log('Load validations failed');
+    console.error('Config validation failed: ', jqXHR, ajaxOptions, error, opt);
   },
 
   /**


Mime
View raw message