You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by wi...@apache.org on 2015/01/02 15:36:32 UTC

[40/50] [abbrv] git commit: updated refs/heads/reporter to b26f3fc

CLOUDSTACK-8122. Handle NPE thrown during migration failures.
When migration fails instead of returning NULL, throw the exception.


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

Branch: refs/heads/reporter
Commit: a5a65c7b551ee5cc32588997937267b716eff681
Parents: ac491c9
Author: Likitha Shetty <li...@citrix.com>
Authored: Fri Dec 5 16:00:21 2014 +0530
Committer: Likitha Shetty <li...@citrix.com>
Committed: Wed Dec 24 13:33:11 2014 +0530

----------------------------------------------------------------------
 .../orchestration/VolumeOrchestrator.java       |  4 +--
 .../com/cloud/storage/VolumeApiServiceImpl.java | 26 ++++++++++++--------
 2 files changed, 18 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a5a65c7b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
index e04bd6d..1b87ccf 100644
--- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
@@ -937,10 +937,10 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
             return result.getVolume();
         } catch (InterruptedException e) {
             s_logger.debug("migrate volume failed", e);
-            return null;
+            throw new CloudRuntimeException(e.getMessage());
         } catch (ExecutionException e) {
             s_logger.debug("migrate volume failed", e);
-            return null;
+            throw new CloudRuntimeException(e.getMessage());
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a5a65c7b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
index c1652ed..7fa600a 100644
--- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java
+++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
@@ -1795,6 +1795,8 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
                 if (jobResult != null) {
                     if (jobResult instanceof ConcurrentOperationException)
                         throw (ConcurrentOperationException)jobResult;
+                    else if (jobResult instanceof RuntimeException)
+                        throw (RuntimeException)jobResult;
                     else if (jobResult instanceof Throwable)
                         throw new RuntimeException("Unexpected exception", (Throwable)jobResult);
                 }
@@ -1817,35 +1819,39 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
         assert (destPool != null);
 
         Volume newVol = null;
-        if (liveMigrateVolume) {
-            newVol = liveMigrateVolume(vol, destPool);
-        } else {
-            try {
+        try {
+            if (liveMigrateVolume) {
+                newVol = liveMigrateVolume(vol, destPool);
+            } else {
                 newVol = _volumeMgr.migrateVolume(vol, destPool);
-            } catch (StorageUnavailableException e) {
-                s_logger.debug("Failed to migrate volume", e);
             }
+        } catch (StorageUnavailableException e) {
+            s_logger.debug("Failed to migrate volume", e);
+            throw new CloudRuntimeException(e.getMessage());
+        }  catch (Exception e) {
+            s_logger.debug("Failed to migrate volume", e);
+            throw new CloudRuntimeException(e.getMessage());
         }
         return newVol;
     }
 
     @DB
-    protected Volume liveMigrateVolume(Volume volume, StoragePool destPool) {
+    protected Volume liveMigrateVolume(Volume volume, StoragePool destPool) throws StorageUnavailableException {
         VolumeInfo vol = volFactory.getVolume(volume.getId());
         AsyncCallFuture<VolumeApiResult> future = volService.migrateVolume(vol, (DataStore)destPool);
         try {
             VolumeApiResult result = future.get();
             if (result.isFailed()) {
                 s_logger.debug("migrate volume failed:" + result.getResult());
-                return null;
+                throw new StorageUnavailableException("Migrate volume failed: " + result.getResult(), destPool.getId());
             }
             return result.getVolume();
         } catch (InterruptedException e) {
             s_logger.debug("migrate volume failed", e);
-            return null;
+            throw new CloudRuntimeException(e.getMessage());
         } catch (ExecutionException e) {
             s_logger.debug("migrate volume failed", e);
-            return null;
+            throw new CloudRuntimeException(e.getMessage());
         }
     }