Roy Golan has uploaded a new change for review.

Change subject: core: better general VDSM exception handling
......................................................................

core: better general VDSM exception handling

refactor error translation to separate network exceptions and protocol
exception so error on XML formatting could be propagated and logged
correctly.

Change-Id: Id2391ec81626cd984f64b9a738adca9be4116d5a
Signed-off-by: Roy Golan <[email protected]>
Bug-Url: https://bugzilla.redhat.com/875725
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllErrors.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerCommand.java
3 files changed, 14 insertions(+), 20 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/79/9479/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java
index b171e56..7bb60cc 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java
@@ -211,6 +211,7 @@
                 switch (errorCode) {
                 case Done: // should never get here with errorCode = 'Done' 
though
                 case exist:
+                case PROTOCOL_ERROR: // probably wrong xml format sent.
                     throw e;
                 default:
                 }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllErrors.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllErrors.java
index a213129..6c14b80 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllErrors.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllErrors.java
@@ -354,6 +354,7 @@
     // oVirt errors
     ENGINE(5001),
     DB(5002),
+    PROTOCOL_ERROR(5003),
     // The VDS does not exist in memory
     RESOURCE_MANAGER_VDS_NOT_FOUND(5004),
     IRS_IMAGE_STATUS_ILLEGAL(5006),
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerCommand.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerCommand.java
index 361aaf9..f608d23 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerCommand.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerCommand.java
@@ -4,6 +4,7 @@
 
 import org.apache.commons.lang.exception.ExceptionUtils;
 import org.ovirt.engine.core.common.businessentities.VDS;
+import org.ovirt.engine.core.common.errors.VDSError;
 import org.ovirt.engine.core.common.errors.VdcBLLException;
 import org.ovirt.engine.core.common.errors.VdcBllErrors;
 import org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase;
@@ -19,6 +20,7 @@
 public abstract class VdsBrokerCommand<P extends 
VdsIdVDSCommandParametersBase> extends BrokerCommandBase<P> {
     private final IVdsServer mVdsBroker;
     private VDS mVds;
+    private static final String msgFormat = "XML RPC error in command {0} ( 
{1} ), the error was: {2}, {3} ";
 
     /**
      * Construct the command using the parameters and the {@link VDS} which is 
loaded from the DB.
@@ -98,37 +100,27 @@
             PrintReturnValue();
             throw new VDSProtocolException(ex);
         } catch (XmlRpcRunTimeException ex) {
-            final String msgFormat = "XML RPC error in command {0} ( {1} ), 
the error was: {2}, {3} ";
-            if ((ExceptionUtils.getRootCause(ex) instanceof ConnectException)) 
{
+            Throwable rootCause = ExceptionUtils.getRootCause(ex);
+            if ((ex.isNetworkError() || rootCause instanceof 
ConnectException)) {
                 log.debugFormat(msgFormat,
                         getCommandName(),
                         getAdditionalInformation(),
                         ex.getMessage(),
-                        ExceptionUtils.getRootCauseMessage(ex));
+                        rootCause.getMessage());
+                PrintReturnValue();
+                throw new VDSNetworkException(ex);
             } else {
                 log.errorFormat(msgFormat,
                         getCommandName(),
                         getAdditionalInformation(),
                         ex.getMessage(),
-                        ExceptionUtils.getRootCauseMessage(ex));
+                        rootCause.getMessage());
+                PrintReturnValue();
+                VDSProtocolException vdsProtocolException = new 
VDSProtocolException(rootCause.getMessage());
+                vdsProtocolException.setVdsError(new 
VDSError(VdcBllErrors.PROTOCOL_ERROR, rootCause.getMessage()));
+                throw vdsProtocolException;
             }
-            PrintReturnValue();
-            throw new VDSNetworkException(ex);
         }
-        // catch (WebException ex)
-        // {
-        // // log this exception in debug becaue it is being logged again 
later.
-        // log.infoFormat("Failed in {0} method", getCommandName());
-        // log.info("Exception", ex);
-        // throw new VDSNetworkException(ex);
-        // }
-
-        // catch (NullReferenceException ex)
-        // {
-        // PrintReturnValue();
-        // //This is a workaround a bug in the xml-rpc package
-        // throw new VDSNetworkException(ex);
-        // }
 
         // TODO: look for invalid certificates error handling
         catch (RuntimeException e) {


--
To view, visit http://gerrit.ovirt.org/9479
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id2391ec81626cd984f64b9a738adca9be4116d5a
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Roy Golan <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to