cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject git commit: updated refs/heads/4.4 to 7db6ba0
Date Wed, 26 Mar 2014 13:56:28 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/4.4 f16dc3fd9 -> 7db6ba0c5


CLOUDSTACK-5432: potential bugs in case of stop mgt server while
template is downloading, template_store_ref has leftover not in ready
state, when create vm from that template, the code doesn't check either
zone id, nor template_store_ref state.

Conflicts:
	engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java


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

Branch: refs/heads/4.4
Commit: 7db6ba0c5fff8a771017ec8bce124fba698efb4e
Parents: f16dc3f
Author: edison <sudison@gmail.com>
Authored: Tue Mar 18 12:20:14 2014 +0100
Committer: Daan Hoogland <daan@onecht.net>
Committed: Wed Mar 26 14:55:21 2014 +0100

----------------------------------------------------------------------
 .../subsystem/api/storage/TemplateDataFactory.java  |  2 ++
 .../engine/orchestration/VolumeOrchestrator.java    |  7 ++++++-
 .../storage/datastore/db/TemplateDataStoreDao.java  |  2 ++
 .../storage/image/TemplateDataFactoryImpl.java      | 12 ++++++++++++
 .../storage/image/db/TemplateDataStoreDaoImpl.java  | 16 ++++++++++++++++
 5 files changed, 38 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7db6ba0c/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/TemplateDataFactory.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/TemplateDataFactory.java
b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/TemplateDataFactory.java
index 801c442..fd22da1 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/TemplateDataFactory.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/TemplateDataFactory.java
@@ -25,6 +25,8 @@ import com.cloud.storage.DataStoreRole;
 public interface TemplateDataFactory {
     TemplateInfo getTemplate(long templateId, DataStore store);
 
+    TemplateInfo getReadyTemplateOnImageStore(long templateId, Long zoneId);
+
     TemplateInfo getTemplate(DataObject obj, DataStore store);
 
     TemplateInfo getTemplate(long templateId, DataStoreRole storeRole);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7db6ba0c/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 767eab2..75a23e0 100644
--- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
@@ -1152,7 +1152,12 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
 
                 future = volService.createVolumeAsync(volume, destPool);
             } else {
-                TemplateInfo templ = tmplFactory.getTemplate(templateId, DataStoreRole.Image);
+    
+                TemplateInfo templ = tmplFactory.getReadyTemplateOnImageStore(templateId,
dest.getDataCenter().getId());
+                if (templ == null) {
+                    s_logger.debug("can't find ready template: " + templateId + " for data
center " + dest.getDataCenter().getId());
+                    throw new CloudRuntimeException("can't find ready template: " + templateId
+ " for data center " + dest.getDataCenter().getId());
+                }
 
                 PrimaryDataStore primaryDataStore = (PrimaryDataStore)destPool;
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7db6ba0c/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java
b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java
index ab45889..271bbca 100644
--- a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java
@@ -65,6 +65,8 @@ public interface TemplateDataStoreDao extends GenericDao<TemplateDataStoreVO,
Lo
 
     List<TemplateDataStoreVO> listByTemplate(long templateId);
 
+    TemplateDataStoreVO findByTemplateZoneReady(long templateId, Long zoneId);
+
     void duplicateCacheRecordsOnRegionStore(long storeId);
 
     TemplateDataStoreVO findReadyOnCache(long templateId);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7db6ba0c/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateDataFactoryImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateDataFactoryImpl.java
b/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateDataFactoryImpl.java
index db28a05..036d797 100644
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateDataFactoryImpl.java
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateDataFactoryImpl.java
@@ -23,6 +23,7 @@ import java.util.List;
 
 import javax.inject.Inject;
 
+import com.cloud.utils.exception.CloudRuntimeException;
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 
@@ -107,6 +108,17 @@ public class TemplateDataFactoryImpl implements TemplateDataFactory {
     }
 
     @Override
+    public TemplateInfo getReadyTemplateOnImageStore(long templateId, Long zoneId) {
+        TemplateDataStoreVO tmplStore = templateStoreDao.findByTemplateZoneReady(templateId,
zoneId);
+        if (tmplStore != null) {
+            DataStore store = storeMgr.getDataStore(tmplStore.getDataStoreId(), DataStoreRole.Image);
+            return this.getTemplate(templateId, store);
+        } else {
+            return null;
+        }
+    }
+
+    @Override
     public TemplateInfo getTemplate(DataObject obj, DataStore store) {
         TemplateObject tmpObj = (TemplateObject)this.getTemplate(obj.getId(), store);
         // carry over url set in passed in data object, for copyTemplate case

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7db6ba0c/engine/storage/src/org/apache/cloudstack/storage/image/db/TemplateDataStoreDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/db/TemplateDataStoreDaoImpl.java
b/engine/storage/src/org/apache/cloudstack/storage/image/db/TemplateDataStoreDaoImpl.java
index d4b0445..cce7f08 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/image/db/TemplateDataStoreDaoImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/image/db/TemplateDataStoreDaoImpl.java
@@ -400,6 +400,22 @@ public class TemplateDataStoreDaoImpl extends GenericDaoBase<TemplateDataStoreVO
         return null;
     }
 
+    @Override
+    public TemplateDataStoreVO findByTemplateZoneReady(long templateId, Long zoneId) {
+        List<DataStore> imgStores = null;
+        imgStores = _storeMgr.getImageStoresByScope(new ZoneScope(zoneId));
+        if (imgStores != null) {
+            Collections.shuffle(imgStores);
+            for (DataStore store : imgStores) {
+                List<TemplateDataStoreVO> sRes = listByTemplateStoreStatus(templateId,
store.getId(), State.Ready);
+                if (sRes != null && sRes.size() > 0) {
+                    return sRes.get(0);
+                }
+            }
+        }
+        return null;
+    }
+
     /**
      * Duplicate all image cache store entries
      */


Mime
View raw message