You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jo...@apache.org on 2014/09/16 14:50:42 UTC
[02/27] git commit: AMBARI-7270. FE: Errors in /recommendation API
being silently ignored
AMBARI-7270. FE: Errors in /recommendation API being silently ignored
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/a96b3f8f
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/a96b3f8f
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/a96b3f8f
Branch: refs/heads/branch-alerts-dev
Commit: a96b3f8fec14bef2b14a729c9e2a9617f757677e
Parents: 1dcb9dc
Author: Srimanth Gunturi <sg...@hortonworks.com>
Authored: Fri Sep 12 17:41:26 2014 -0700
Committer: Srimanth Gunturi <sg...@hortonworks.com>
Committed: Fri Sep 12 19:24:45 2014 -0700
----------------------------------------------------------------------
.../stackadvisor/StackAdvisorRunner.java | 10 +++-
.../RecommendationResourceProvider.java | 6 +--
.../internal/ValidationResourceProvider.java | 6 +--
.../app/controllers/wizard/step5_controller.js | 54 ++++++++++++--------
.../app/controllers/wizard/step6_controller.js | 31 +++++++----
.../app/controllers/wizard/step7_controller.js | 15 +++++-
ambari-web/app/mixins/common/serverValidator.js | 8 +--
7 files changed, 84 insertions(+), 46 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/a96b3f8f/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorRunner.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorRunner.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorRunner.java
index ee7dcc2..a50f915 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorRunner.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorRunner.java
@@ -75,7 +75,15 @@ public class StackAdvisorRunner {
if (exitCode > 0) {
String errorMessage;
if (errMessage != null) {
- errorMessage = errMessage.substring(errMessage.lastIndexOf("\n"));
+ // We want to get the last line.
+ int index = errMessage.lastIndexOf("\n");
+ if (index > 0 && index == (errMessage.length() - 1)) {
+ index = errMessage.lastIndexOf("\n", index - 1); // sentence ended with newline
+ }
+ if (index > -1) {
+ errMessage = errMessage.substring(index + 1).trim();
+ }
+ errorMessage = errMessage;
} else {
errorMessage = "Error occurred during stack advisor execution";
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/a96b3f8f/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RecommendationResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RecommendationResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RecommendationResourceProvider.java
index b722825..40a1791 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RecommendationResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RecommendationResourceProvider.java
@@ -93,12 +93,10 @@ public class RecommendationResourceProvider extends StackAdvisorResourceProvider
response = saHelper.recommend(recommendationRequest);
} catch (StackAdvisorRequestException e) {
LOG.warn("Error occured during recommnedation", e);
- throw new WebApplicationException(Response.status(Status.BAD_REQUEST).entity(e.getMessage())
- .build());
+ throw new IllegalArgumentException(e.getMessage(), e);
} catch (StackAdvisorException e) {
LOG.warn("Error occured during recommnedation", e);
- throw new WebApplicationException(Response.status(Status.INTERNAL_SERVER_ERROR).entity(e.getMessage())
- .build());
+ throw new SystemException(e.getMessage(), e);
}
Resource recommendation = createResources(new Command<Resource>() {
http://git-wip-us.apache.org/repos/asf/ambari/blob/a96b3f8f/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ValidationResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ValidationResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ValidationResourceProvider.java
index 941fb19..d77cf7d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ValidationResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ValidationResourceProvider.java
@@ -85,12 +85,10 @@ public class ValidationResourceProvider extends StackAdvisorResourceProvider {
response = saHelper.validate(validationRequest);
} catch (StackAdvisorRequestException e) {
LOG.warn("Error occurred during validation", e);
- throw new WebApplicationException(Response.status(Status.BAD_REQUEST).entity(e.getMessage())
- .build());
+ throw new IllegalArgumentException(e.getMessage(), e);
} catch (StackAdvisorException e) {
LOG.warn("Error occurred during validation", e);
- throw new WebApplicationException(Response.status(Status.INTERNAL_SERVER_ERROR).entity(e.getMessage())
- .build());
+ throw new SystemException(e.getMessage(), e);
}
Resource validation = createResources(new Command<Resource>() {
http://git-wip-us.apache.org/repos/asf/ambari/blob/a96b3f8f/ambari-web/app/controllers/wizard/step5_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step5_controller.js b/ambari-web/app/controllers/wizard/step5_controller.js
index e08e709..258e856 100644
--- a/ambari-web/app/controllers/wizard/step5_controller.js
+++ b/ambari-web/app/controllers/wizard/step5_controller.js
@@ -281,19 +281,13 @@ App.WizardStep5Controller = Em.Controller.extend(App.BlueprintMixin, {
validate: 'host_groups',
recommendations: blueprint
},
- success: 'updateValidationsSuccessCallback'
+ success: 'updateValidationsSuccessCallback',
+ error: 'updateValidationsErrorCallback'
}).
- retry({
- times: App.maxRetries,
- timeout: App.timeout
- }).
then(function() {
if (callback) {
callback();
}
- }, function () {
- App.showReloadPopup();
- console.log('Load validations failed');
}
);
},
@@ -306,8 +300,8 @@ App.WizardStep5Controller = Em.Controller.extend(App.BlueprintMixin, {
updateValidationsSuccessCallback: function (data) {
var self = this;
- generalErrorMessages = [];
- generalWarningMessages = [];
+ var generalErrorMessages = [];
+ var generalWarningMessages = [];
this.get('servicesMasters').setEach('warnMessage', null);
this.get('servicesMasters').setEach('errorMessage', null);
var anyErrors = false;
@@ -344,6 +338,19 @@ App.WizardStep5Controller = Em.Controller.extend(App.BlueprintMixin, {
},
/**
+ * Error-callback for validations request
+ * @param {object} jqXHR
+ * @param {object} ajaxOptions
+ * @param {string} error
+ * @param {object} opt
+ * @method updateValidationsErrorCallback
+ */
+ updateValidationsErrorCallback: function (jqXHR, ajaxOptions, error, opt) {
+ App.ajax.defaultErrorHandler(jqXHR, opt.url, opt.method, jqXHR.status);
+ console.log('Load validations failed');
+ },
+
+ /**
* Composes selected values of comboboxes into master blueprint + merge it with currenlty installed slave blueprint
*/
getCurrentBlueprint: function() {
@@ -532,20 +539,12 @@ App.WizardStep5Controller = Em.Controller.extend(App.BlueprintMixin, {
name: 'wizard.loadrecommendations',
sender: self,
data: data,
- success: 'loadRecommendationsSuccessCallback'
+ success: 'loadRecommendationsSuccessCallback',
+ error: 'loadRecommendationsErrorCallback'
}).
- retry({
- times: App.maxRetries,
- timeout: App.timeout
- }).
then(function () {
callback(self.createComponentInstallationObjects(), self);
- },
- function () {
- App.showReloadPopup();
- console.log('Load recommendations failed');
- }
- );
+ });
}
},
@@ -648,6 +647,19 @@ App.WizardStep5Controller = Em.Controller.extend(App.BlueprintMixin, {
},
/**
+ * Error-callback for recommendations request
+ * @param {object} jqXHR
+ * @param {object} ajaxOptions
+ * @param {string} error
+ * @param {object} opt
+ * @method loadRecommendationsErrorCallback
+ */
+ loadRecommendationsErrorCallback: function (jqXHR, ajaxOptions, error, opt) {
+ App.ajax.defaultErrorHandler(jqXHR, opt.url, opt.method, jqXHR.status);
+ console.log('Load recommendations failed');
+ },
+
+ /**
* Load services info to appropriate variable and return masterComponentHosts
* @return {Object[]}
*/
http://git-wip-us.apache.org/repos/asf/ambari/blob/a96b3f8f/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 3bd11c5..1142c8a 100644
--- a/ambari-web/app/controllers/wizard/step6_controller.js
+++ b/ambari-web/app/controllers/wizard/step6_controller.js
@@ -69,7 +69,7 @@ App.WizardStep6Controller = Em.Controller.extend(App.BlueprintMixin, {
* Define state for submit button
* @type {bool}
*/
- submitDisabled: true,
+ submitDisabled: false,
/**
* Check if <code>addHostWizard</code> used
@@ -544,7 +544,9 @@ App.WizardStep6Controller = Em.Controller.extend(App.BlueprintMixin, {
*/
callServerSideValidation: function (successCallback) {
var self = this;
- self.set('submitDisabled', true);
+
+ // We do not want to disable Next due to server validation issues - hence commented out line below
+ // self.set('submitDisabled', true);
var selectedServices = App.StackService.find().filterProperty('isSelected').mapProperty('serviceName');
var installedServices = App.StackService.find().filterProperty('isInstalled').mapProperty('serviceName');
@@ -593,19 +595,13 @@ App.WizardStep6Controller = Em.Controller.extend(App.BlueprintMixin, {
validate: 'host_groups',
recommendations: bluePrintsForValidation
},
- success: 'updateValidationsSuccessCallback'
+ success: 'updateValidationsSuccessCallback',
+ error: 'updateValidationsErrorCallback'
}).
- retry({
- times: App.maxRetries,
- timeout: App.timeout
- }).
then(function () {
if (!self.get('submitDisabled') && successCallback) {
successCallback();
}
- }, function () {
- App.showReloadPopup();
- console.log('Load validations failed');
}
);
},
@@ -690,7 +686,20 @@ App.WizardStep6Controller = Em.Controller.extend(App.BlueprintMixin, {
// use this.set('submitDisabled', anyErrors); is validation results should block next button
// It's because showValidationIssuesAcceptBox allow use accept validation issues and continue
- this.set('submitDisabled', false);
+ // this.set('submitDisabled', false);
+ },
+
+ /**
+ * Error-callback for validations request
+ * @param {object} jqXHR
+ * @param {object} ajaxOptions
+ * @param {string} error
+ * @param {object} opt
+ * @method updateValidationsErrorCallback
+ */
+ updateValidationsErrorCallback: function (jqXHR, ajaxOptions, error, opt) {
+ App.ajax.defaultErrorHandler(jqXHR, opt.url, opt.method, jqXHR.status);
+ console.log('Load validations failed');
},
/**
http://git-wip-us.apache.org/repos/asf/ambari/blob/a96b3f8f/ambari-web/app/controllers/wizard/step7_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step7_controller.js b/ambari-web/app/controllers/wizard/step7_controller.js
index 45647bb..414dfdd 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -1343,11 +1343,22 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, {
}
var self = this;
this.set('submitButtonClicked', true);
- this.serverSideValidation().done(function () {
- self.checkDatabaseConnectionTest().done(function () {
+ this.serverSideValidation().done(function() {
+ self.checkDatabaseConnectionTest().done(function() {
self.resolveHiveMysqlDatabase();
self.set('submitButtonClicked', false);
});
+ }).fail(function(value){
+ if ("invalid_configs" == value) {
+ self.set('submitButtonClicked', false);
+ } else {
+ // Failed due to validation mechanism failure.
+ // Should proceed with other checks
+ self.checkDatabaseConnectionTest().done(function() {
+ self.resolveHiveMysqlDatabase();
+ self.set('submitButtonClicked', false);
+ });
+ }
});
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/a96b3f8f/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 b520071..bea7bd7 100644
--- a/ambari-web/app/mixins/common/serverValidator.js
+++ b/ambari-web/app/mixins/common/serverValidator.js
@@ -134,7 +134,8 @@ App.ServerValidatorMixin = Em.Mixin.create({
this.set("recommendationsConfigs", Em.get(data.resources[0] , "recommendations.blueprint.configurations"));
},
- loadRecommendationsError: function() {
+ loadRecommendationsError: function(jqXHR, ajaxOptions, error, opt) {
+ App.ajax.defaultErrorHandler(jqXHR, opt.url, opt.method, jqXHR.status);
console.error('Load recommendations failed');
},
@@ -251,8 +252,9 @@ App.ServerValidatorMixin = Em.Mixin.create({
});
},
- validationError: function() {
+ 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');
},
@@ -279,7 +281,7 @@ App.ServerValidatorMixin = Em.Mixin.create({
},
onSecondary: function () {
this.hide();
- deferred.reject();
+ deferred.reject("invalid_configs"); // message used to differentiate types of rejections.
},
bodyClass: Em.View.extend({
controller: self,