You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by da...@apache.org on 2020/04/23 12:24:15 UTC

[cloudstack] 02/03: Update AncientDataMotionStrategy.java

This is an automated email from the ASF dual-hosted git repository.

dahn pushed a commit to branch volume-migration
in repository https://gitbox.apache.org/repos/asf/cloudstack.git

commit 113ec9cc9979b77c08104513467bd0999c520704
Author: div8cn <35...@users.noreply.github.com>
AuthorDate: Wed Apr 22 19:49:51 2020 +0800

    Update AncientDataMotionStrategy.java
    
    Volume is migrated across Primary storage. If no secondary storage is available(Or used capacity> 90% ), the migration is canceled.
    Before modification, if secondary storage cannot be found, copyVolumeBetweenPools return NUll
    
    copyAsync considers answer = null to be a sign of successful task execution, so it deletes the VOLUME on the old primary storage. This is the root cause of data loss, because VOLUME did not perform the migration at all.
---
 .../cloudstack/storage/motion/AncientDataMotionStrategy.java     | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java b/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
index 327ff67..1c59515 100644
--- a/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
+++ b/engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
@@ -330,8 +330,10 @@ public class AncientDataMotionStrategy implements DataMotionStrategy {
             // directly to s3
             ImageStoreEntity imageStore = (ImageStoreEntity)dataStoreMgr.getImageStoreWithFreeCapacity(destScope.getScopeId());
             if (imageStore == null || !imageStore.getProtocol().equalsIgnoreCase("nfs") && !imageStore.getProtocol().equalsIgnoreCase("cifs")) {
-                s_logger.debug("can't find a nfs (or cifs) image store to satisfy the need for a staging store");
-                return null;
+                //s_logger.debug("can't find a nfs (or cifs) image store to satisfy the need for a staging store");
+                String errMsg = "can't find a nfs (or cifs) image store to satisfy the need for a staging store";
+                Answer answer = new Answer(null, false, errMsg);
+                return answer;
             }
 
             DataObject objOnImageStore = imageStore.create(srcData);
@@ -468,9 +470,6 @@ public class AncientDataMotionStrategy implements DataMotionStrategy {
             if (answer != null && !answer.getResult()) {
                 errMsg = answer.getDetails();
             }
-            if (answer == null) {
-                errMsg = "answer is null, set to error for CopyCommandResult";
-            }
         } catch (Exception e) {
             s_logger.debug("copy failed", e);
             errMsg = e.toString();