From 326d6f9e26f1a2f1d4d95ff3a99e7476d0711173 Mon Sep 17 00:00:00 2001 From: div8cn <35140268+div8cn@users.noreply.github.com> Date: Tue, 10 Mar 2020 23:04:18 +0800 Subject: [PATCH 1/3] Update AncientDataMotionStrategy.java fix When secondary storage usage is> 90%, VOLUME migration across primary storage will cause the migration to fail and lose VOLUME --- .../cloudstack/storage/motion/AncientDataMotionStrategy.java | 3 +++ 1 file changed, 3 insertions(+) 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 bc49a53db581..327ff67a9689 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 @@ -468,6 +468,9 @@ public void copyAsync(DataObject srcData, DataObject destData, Host destHost, As 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(); From 113ec9cc9979b77c08104513467bd0999c520704 Mon Sep 17 00:00:00 2001 From: div8cn <35140268+div8cn@users.noreply.github.com> Date: Wed, 22 Apr 2020 19:49:51 +0800 Subject: [PATCH 2/3] 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. --- .../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 327ff67a9689..1c5951590456 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 @@ protected Answer copyVolumeBetweenPools(DataObject srcData, DataObject destData) // 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 void copyAsync(DataObject srcData, DataObject destData, Host destHost, As 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(); From 9fce86b31cd87e54c4ab7ce968a05a3232c45bae Mon Sep 17 00:00:00 2001 From: Daan Hoogland Date: Thu, 23 Apr 2020 12:13:24 +0000 Subject: [PATCH 3/3] code in comment removed --- .../cloudstack/storage/motion/AncientDataMotionStrategy.java | 1 - 1 file changed, 1 deletion(-) 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 1c5951590456..a5b01c70679c 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,7 +330,6 @@ protected Answer copyVolumeBetweenPools(DataObject srcData, DataObject destData) // 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"); 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;