CLOUDSTACK-7412: Can't create proper template from VM on S3 secondary storage 
environment

Signed-off-by: Rajani Karuturi <rajanikarut...@gmail.com>


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

Branch: refs/heads/useraccount-refactoring
Commit: 9d31e59d5b54ef64475e6e8ea36c3e2fc2e7f379
Parents: 488c178
Author: Hiroki Ohashi <hiroki.ooha...@aist.go.jp>
Authored: Thu Nov 27 19:13:36 2014 +0900
Committer: Rajani Karuturi <rajanikarut...@gmail.com>
Committed: Thu Nov 27 17:07:27 2014 +0530

----------------------------------------------------------------------
 .../storage/motion/AncientDataMotionStrategy.java | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9d31e59d/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
----------------------------------------------------------------------
diff --git 
a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
 
b/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
index 5b01f95..203cfa4 100644
--- 
a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
+++ 
b/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java
@@ -174,15 +174,29 @@ public class AncientDataMotionStrategy implements 
DataMotionStrategy {
             }
 
             if (cacheData != null) {
-                if (srcData.getType() == DataObjectType.VOLUME && 
destData.getType() == DataObjectType.VOLUME) {
-                    // volume transfer from primary to secondary or vice 
versa. Volume transfer between primary pools are already handled by 
copyVolumeBetweenPools
+                final Long cacheId = cacheData.getId();
+                final String cacheType = cacheData.getType().toString();
+                final String cacheUuid = cacheData.getUuid().toString();
+
+                if (srcData.getType() == DataObjectType.VOLUME &&
+                    (destData.getType() == DataObjectType.VOLUME ||
+                     destData.getType() == DataObjectType.TEMPLATE)) {
+                    // volume transfer from primary to secondary. Volume 
transfer between primary pools are already handled by copyVolumeBetweenPools
+                    // Delete cache in order to certainly transfer a latest 
image.
+                    s_logger.debug("Delete " + cacheType + " cache(id: " + 
cacheId +
+                                   ", uuid: " + cacheUuid + ")");
                     cacheMgr.deleteCacheObject(srcForCopy);
                 } else {
                     // for template, we want to leave it on cache for 
performance reason
                     if ((answer == null || !answer.getResult()) && 
srcForCopy.getRefCount() < 2) {
                         // cache object created by this copy, not already there
+                        s_logger.warn("Copy may not be handled correctly by 
agent(id: " + ep.getId() + ")." +
+                                      " Delete " + cacheType + " cache(id: " + 
cacheId +
+                                      ", uuid: " + cacheUuid + ")");
                         cacheMgr.deleteCacheObject(srcForCopy);
                     } else {
+                        s_logger.debug("Decrease reference count of " + 
cacheType +
+                                       " cache(id: " + cacheId + ", uuid: " + 
cacheUuid + ")");
                         cacheMgr.releaseCacheObject(srcForCopy);
                     }
                 }

Reply via email to