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 2014/11/20 01:13:20 UTC
git commit: updated refs/heads/master to 4140811
Repository: cloudstack
Updated Branches:
refs/heads/master 2ccecce51 -> 414081154
CLOUDSTACK-7947:
double check if parent snapshot is removed or not, when creating new
snapshot
Reviewed-by: Min
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/41408115
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/41408115
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/41408115
Branch: refs/heads/master
Commit: 414081154942ff03bd4b73dd834eeec559608799
Parents: 2ccecce
Author: Edison Su <su...@gmail.com>
Authored: Wed Nov 12 12:07:49 2014 -0800
Committer: Edison Su <su...@gmail.com>
Committed: Wed Nov 19 16:13:05 2014 -0800
----------------------------------------------------------------------
.../storage/snapshot/XenserverSnapshotStrategy.java | 4 ++++
.../storage/datastore/ObjectInDataStoreManagerImpl.java | 9 ++++++++-
.../src/com/cloud/storage/snapshot/SnapshotManagerImpl.java | 4 +++-
3 files changed, 15 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/41408115/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java
index 8d6886e..90efcde 100644
--- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java
+++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java
@@ -198,6 +198,10 @@ public class XenserverSnapshotStrategy extends SnapshotStrategyBase {
}
if (Snapshot.State.Error.equals(snapshotVO.getState())) {
+ List<SnapshotDataStoreVO> storeRefs = snapshotStoreDao.findBySnapshotId(snapshotId);
+ for (SnapshotDataStoreVO ref : storeRefs) {
+ snapshotStoreDao.expunge(ref.getId());
+ }
snapshotDao.remove(snapshotId);
return true;
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/41408115/engine/storage/src/org/apache/cloudstack/storage/datastore/ObjectInDataStoreManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/ObjectInDataStoreManagerImpl.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/ObjectInDataStoreManagerImpl.java
index fbce860..fa91e4f 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/ObjectInDataStoreManagerImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/ObjectInDataStoreManagerImpl.java
@@ -45,6 +45,7 @@ import com.cloud.agent.api.to.DataObjectType;
import com.cloud.agent.api.to.S3TO;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.storage.DataStoreRole;
+import com.cloud.storage.SnapshotVO;
import com.cloud.storage.VMTemplateStoragePoolVO;
import com.cloud.storage.dao.SnapshotDao;
import com.cloud.storage.dao.VMTemplateDao;
@@ -119,7 +120,13 @@ public class ObjectInDataStoreManagerImpl implements ObjectInDataStoreManager {
ss.setPhysicalSize(snapshotInfo.getSize()); // this physical size will get updated with actual size once the snapshot backup is done.
SnapshotDataStoreVO snapshotDataStoreVO = snapshotDataStoreDao.findParent(dataStore.getRole(), dataStore.getId(), snapshotInfo.getVolumeId());
if (snapshotDataStoreVO != null) {
- ss.setParentSnapshotId(snapshotDataStoreVO.getSnapshotId());
+ //Double check the snapshot is removed or not
+ SnapshotVO parentSnap = snapshotDao.findById(snapshotDataStoreVO.getSnapshotId());
+ if (parentSnap != null) {
+ ss.setParentSnapshotId(snapshotDataStoreVO.getSnapshotId());
+ } else {
+ s_logger.debug("find inconsistent db for snapshot " + snapshotDataStoreVO.getSnapshotId());
+ }
}
ss.setState(ObjectInDataStoreStateMachine.State.Allocated);
ss = snapshotDataStoreDao.persist(ss);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/41408115/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
index bcb2242..04a0489 100755
--- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
+++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
@@ -26,7 +26,6 @@ import javax.ejb.Local;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
-import org.apache.cloudstack.api.command.user.snapshot.UpdateSnapshotPolicyCmd;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
@@ -34,6 +33,7 @@ import org.apache.cloudstack.api.command.user.snapshot.CreateSnapshotPolicyCmd;
import org.apache.cloudstack.api.command.user.snapshot.DeleteSnapshotPoliciesCmd;
import org.apache.cloudstack.api.command.user.snapshot.ListSnapshotPoliciesCmd;
import org.apache.cloudstack.api.command.user.snapshot.ListSnapshotsCmd;
+import org.apache.cloudstack.api.command.user.snapshot.UpdateSnapshotPolicyCmd;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
@@ -1148,4 +1148,6 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
return snapshot;
}
+
+
}