cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mc...@apache.org
Subject [2/2] git commit: updated refs/heads/master to df1c34b
Date Wed, 11 Dec 2013 22:34:36 GMT
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/df1c34bf
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/df1c34bf
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/df1c34bf

Branch: refs/heads/master
Commit: df1c34bf2b072698ece764d9ddeae3be5e0a4264
Parents: 010b007
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:18:06 2013 -0800

----------------------------------------------------------------------
 .../storage/image/TemplateServiceImpl.java      | 26 +++++++++++++++++---
 .../storage/volume/VolumeServiceImpl.java       | 16 ++++++++++--
 2 files changed, 37 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/df1c34bf/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 dbd95e8..9e03042 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;
@@ -392,9 +394,16 @@ public class TemplateServiceImpl implements TemplateService {
                             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());
+                                }
                             }
                         }
                     }
@@ -424,6 +433,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());
                                 associateTemplateToZone(tmplt.getId(), zoneId);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/df1c34bf/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 9f71abd..37e5bb4 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;
@@ -1228,6 +1229,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