cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mc...@apache.org
Subject [1/2] git commit: updated refs/heads/4.3 to feb9fe1
Date Wed, 11 Dec 2013 22:09:15 GMT
Updated Branches:
  refs/heads/4.3 2dfa84bf2 -> feb9fe18b


CLOUDSTACK-5451:Restart MS after migrating NFS image store to S3,
previous Ready template is not ready anymore.


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

Branch: refs/heads/4.3
Commit: feb9fe18b89bf59d3e24f8ae3306a76d8b818ff7
Parents: eb64159
Author: Min Chen <min.chen@citrix.com>
Authored: Wed Dec 11 13:58:20 2013 -0800
Committer: Min Chen <min.chen@citrix.com>
Committed: Wed Dec 11 14:02:24 2013 -0800

----------------------------------------------------------------------
 .../storage/image/TemplateServiceImpl.java      | 32 +++++++++++++++-----
 .../storage/volume/VolumeServiceImpl.java       | 16 ++++++++--
 2 files changed, 39 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/feb9fe18/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java
b/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java
index f5f15df..8078e74 100644
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java
@@ -41,6 +41,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
 import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
 import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
 import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.State;
 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.TemplateDataFactory;
@@ -77,6 +78,7 @@ import com.cloud.storage.DataStoreRole;
 import com.cloud.storage.ScopeType;
 import com.cloud.storage.Storage.TemplateType;
 import com.cloud.storage.StoragePool;
+import com.cloud.storage.VMTemplateStorageResourceAssoc;
 import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
 import com.cloud.storage.VMTemplateVO;
 import com.cloud.storage.VMTemplateZoneVO;
@@ -281,7 +283,7 @@ public class TemplateServiceImpl implements TemplateService {
         GlobalLock syncLock = GlobalLock.getInternLock(lockString);
         try {
             if (syncLock.lock(3)) {
-                try{
+                try {
                     Long zoneId = store.getScope().getScopeId();
 
                     Map<String, TemplateProp> templateInfos = listTemplate(store);
@@ -393,14 +395,20 @@ public class TemplateServiceImpl implements TemplateService {
                                 _templateDao.update(tmplt.getId(), tmlpt);
                                 associateTemplateToZone(tmplt.getId(), zoneId);
 
-
                             }
                         } else {
                             s_logger.info("Template Sync did not find " + uniqueName + "
on image store " + storeId + ", may request download based on available hypervisor types");
                             if (tmpltStore != null) {
-                                s_logger.info("Removing leftover template " + uniqueName
+ " entry from template store table");
-                                // remove those leftover entries
-                                _vmTemplateStoreDao.remove(tmpltStore.getId());
+                                if (isRegionStore(store) && tmpltStore.getDownloadState()
== VMTemplateStorageResourceAssoc.Status.DOWNLOADED
+                                        && tmpltStore.getState() == State.Ready
+                                        && tmpltStore.getInstallPath() == null) {
+                                    s_logger.info("Keep fake entry in template store table
for migration of previous NFS to object store");
+                                }
+                                else {
+                                    s_logger.info("Removing leftover template " + uniqueName
+ " entry from template store table");
+                                    // remove those leftover entries
+                                    _vmTemplateStoreDao.remove(tmpltStore.getId());
+                                }
                             }
                         }
                     }
@@ -430,6 +438,17 @@ public class TemplateServiceImpl implements TemplateService {
                                 continue;
                             }
 
+                            // if this is a region store, and there is already an DOWNLOADED
entry there without install_path information, which
+                            // means that this is a duplicate entry from migration of previous
NFS to staging.
+                            if (isRegionStore(store)) {
+                                TemplateDataStoreVO tmpltStore = _vmTemplateStoreDao.findByStoreTemplate(storeId,
tmplt.getId());
+                                if (tmpltStore != null && tmpltStore.getDownloadState()
== VMTemplateStorageResourceAssoc.Status.DOWNLOADED && tmpltStore.getState() == State.Ready
+                                        && tmpltStore.getInstallPath() == null) {
+                                    s_logger.info("Skip sync template for migration of previous
NFS to object store");
+                                    continue;
+                                }
+                            }
+
                             if (availHypers.contains(tmplt.getHypervisorType())) {
                                 s_logger.info("Downloading template " + tmplt.getUniqueName()
+ " to image store "
                                         + store.getName());
@@ -474,8 +493,7 @@ public class TemplateServiceImpl implements TemplateService {
 
                         }
                     }
-                }
-                finally{
+                } finally {
                     syncLock.unlock();
                 }
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/feb9fe18/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
index fc6225c..3cef23d 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
@@ -25,6 +25,9 @@ import java.util.Map;
 
 import javax.inject.Inject;
 
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
 import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
 import org.apache.cloudstack.engine.subsystem.api.storage.ChapInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
@@ -57,8 +60,6 @@ import org.apache.cloudstack.storage.datastore.PrimaryDataStoreProviderManager;
 import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO;
 import org.apache.cloudstack.storage.to.VolumeObjectTO;
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
 
 import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.storage.ListVolumeAnswer;
@@ -1262,6 +1263,17 @@ public class VolumeServiceImpl implements VolumeService {
                                 s_logger.info("Skip downloading volume " + volumeHost.getVolumeId()
+ " since no download url is specified.");
                                 continue;
                             }
+
+                            // if this is a region store, and there is already an DOWNLOADED
entry there without install_path information, which
+                            // means that this is a duplicate entry from migration of previous
NFS to staging.
+                            if (store.getScope().getScopeType() == ScopeType.REGION) {
+                                if (volumeHost.getDownloadState() == VMTemplateStorageResourceAssoc.Status.DOWNLOADED
+                                        && volumeHost.getInstallPath() == null) {
+                                    s_logger.info("Skip sync volume for migration of previous
NFS to object store");
+                                    continue;
+                                }
+                            }
+
                             s_logger.debug("Volume " + volumeHost.getVolumeId() + " needs
to be downloaded to " + store.getName());
                             // TODO: pass a callback later
                             VolumeInfo vol = volFactory.getVolume(volumeHost.getVolumeId());


Mime
View raw message