You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ed...@apache.org on 2013/06/29 01:52:30 UTC

git commit: updated refs/heads/master to 58f9202

Updated Branches:
  refs/heads/master ed0042798 -> 58f920281


CLOUDSTACK-3215: Cannot Deploy VM when using S3 object store without NFS Cache

Signed-off-by: Edison Su <su...@gmail.com>


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

Branch: refs/heads/master
Commit: 58f9202818ffe78f3cd6748fc8710433d11bd5a2
Parents: ed00427
Author: Donal Lafferty <do...@citrix.com>
Authored: Fri Jun 28 16:51:44 2013 -0700
Committer: Edison Su <su...@gmail.com>
Committed: Fri Jun 28 16:52:06 2013 -0700

----------------------------------------------------------------------
 .../cache/manager/StorageCacheManagerImpl.java  |  8 ++-
 .../motion/AncientDataMotionStrategy.java       | 53 +++++++++++++-------
 2 files changed, 42 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/58f92028/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheManagerImpl.java b/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheManagerImpl.java
index 4b4e521..a810772 100644
--- a/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheManagerImpl.java
+++ b/engine/storage/cache/src/org/apache/cloudstack/storage/cache/manager/StorageCacheManagerImpl.java
@@ -147,7 +147,7 @@ public class StorageCacheManagerImpl implements StorageCacheManager, Manager {
                         object = cacheReplacementAlgorithm.chooseOneToBeReplaced(store);
                         findAStore = store;
                         if (object != null) {
-                              break;
+                            break;
                         }
                     }
 
@@ -230,6 +230,12 @@ public class StorageCacheManagerImpl implements StorageCacheManager, Manager {
     @Override
     public DataObject createCacheObject(DataObject data, Scope scope) {
         DataStore cacheStore = this.getCacheStorage(scope);
+
+        if (cacheStore == null)
+        {
+            String errMsg = "No cache DataStore in scope id " + scope.getScopeId() + " type " + scope.getScopeType().toString();
+            throw new CloudRuntimeException(errMsg);
+        }
         return this.createCacheObject(data, cacheStore);
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/58f92028/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 631de6a..04d0436 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
@@ -35,6 +35,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreState
 import org.apache.cloudstack.engine.subsystem.api.storage.Scope;
 import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.StorageCacheManager;
+import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
 import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
@@ -57,6 +58,7 @@ import com.cloud.configuration.Config;
 import com.cloud.configuration.dao.ConfigurationDao;
 import com.cloud.host.Host;
 import com.cloud.host.dao.HostDao;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.storage.DataStoreRole;
 import com.cloud.storage.StorageManager;
 import com.cloud.storage.StoragePool;
@@ -135,6 +137,22 @@ public class AncientDataMotionStrategy implements DataMotionStrategy {
         if (destStoreTO instanceof NfsTO || destStoreTO.getRole() == DataStoreRole.ImageCache) {
             return false;
         }
+
+        if (srcData.getType() == DataObjectType.TEMPLATE) {
+            TemplateInfo template = (TemplateInfo)srcData;
+            if (template.getHypervisorType() == HypervisorType.Hyperv) {
+                if (s_logger.isDebugEnabled()) {
+                    s_logger.debug("needCacheStorage false due to src TemplateInfo, which is DataObjectType.TEMPLATE of HypervisorType.Hyperv");
+                }
+                return false;
+            }
+        }
+
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("needCacheStorage true, dest at " +
+                    destTO.getPath() + " dest role " + destStoreTO.getRole().toString() +
+                    srcTO.getPath() + " src role " + srcStoreTO.getRole().toString() );
+        }
         return true;
     }
 
@@ -157,26 +175,24 @@ public class AncientDataMotionStrategy implements DataMotionStrategy {
         int _primaryStorageDownloadWait = NumbersUtil.parseInt(value,
                 Integer.parseInt(Config.PrimaryStorageDownloadWait.getDefaultValue()));
         Answer answer = null;
+        boolean usingCache = false;
         DataObject cacheData = null;
+        DataObject srcForCopy = srcData;
         try {
             if (needCacheStorage(srcData, destData)) {
-                // need to copy it to image cache store
                 Scope destScope = getZoneScope(destData.getDataStore().getScope());
-                cacheData = cacheMgr.createCacheObject(srcData, destScope);
-                CopyCommand cmd = new CopyCommand(cacheData.getTO(), destData.getTO(), _primaryStorageDownloadWait);
-                EndPoint ep = selector.select(cacheData, destData);
-                answer = ep.sendMessage(cmd);
-            } else {
-                // handle copy it to/from cache store
-                CopyCommand cmd = new CopyCommand(srcData.getTO(), destData.getTO(), _primaryStorageDownloadWait);
-                EndPoint ep = selector.select(srcData, destData);
-                answer = ep.sendMessage(cmd);
+                srcForCopy = cacheData = cacheMgr.createCacheObject(srcData, destScope);
             }
+
+            CopyCommand cmd = new CopyCommand(srcForCopy.getTO(), destData.getTO(), _primaryStorageDownloadWait);
+            EndPoint ep = selector.select(srcForCopy, destData);
+            answer = ep.sendMessage(cmd);
+
             if (cacheData != null) {
                 if (answer == null || !answer.getResult()) {
-                    cacheMgr.deleteCacheObject(cacheData);
+                    cacheMgr.deleteCacheObject(srcForCopy);
                 } else {
-                    cacheMgr.releaseCacheObject(cacheData);
+                    cacheMgr.releaseCacheObject(srcForCopy);
                 }
             }
             return answer;
@@ -187,7 +203,6 @@ public class AncientDataMotionStrategy implements DataMotionStrategy {
             }
             throw new CloudRuntimeException(e.toString());
         }
-
     }
 
     protected DataObject cacheSnapshotChain(SnapshotInfo snapshot) {
@@ -204,10 +219,10 @@ public class AncientDataMotionStrategy implements DataMotionStrategy {
     }
 
     protected void deleteSnapshotCacheChain(SnapshotInfo snapshot) {
-       while (snapshot != null) {
-           cacheMgr.deleteCacheObject(snapshot);
-           snapshot = snapshot.getParent();
-       }
+        while (snapshot != null) {
+            cacheMgr.deleteCacheObject(snapshot);
+            snapshot = snapshot.getParent();
+        }
     }
 
     protected Answer copyVolumeFromSnapshot(DataObject snapObj, DataObject volObj) {
@@ -317,6 +332,8 @@ public class AncientDataMotionStrategy implements DataMotionStrategy {
         Answer answer = null;
         String errMsg = null;
         try {
+            s_logger.debug("copyAsync inspecting src type " + srcData.getType().toString() +
+                    " copyAsync inspecting dest type " + destData.getType().toString());
 
             if (srcData.getType() == DataObjectType.SNAPSHOT && destData.getType() == DataObjectType.VOLUME) {
                 answer = copyVolumeFromSnapshot(srcData, destData);
@@ -404,7 +421,7 @@ public class AncientDataMotionStrategy implements DataMotionStrategy {
 
     @Override
     public Void copyAsync(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost,
-            AsyncCompletionCallback<CopyCommandResult> callback) {
+                          AsyncCompletionCallback<CopyCommandResult> callback) {
         CopyCommandResult result = new CopyCommandResult(null, null);
         result.setResult("Unsupported operation requested for copying data.");
         callback.complete(result);