mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-7301, CLOUDSTACK-7947: double check if parent snapshot is removed or not
when creating new snapshot, check if parent snapshot is removed or not
Reviewed-by: Min
(cherry picked from commit bd79965329)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
Conflicts:
engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java
This commit is contained in:
parent
a15acb8e74
commit
ebf9897293
|
|
@ -202,6 +202,15 @@ public class XenserverSnapshotStrategy extends SnapshotStrategyBase {
|
|||
return true;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if (snapshotVO.getState() == Snapshot.State.CreatedOnPrimary) {
|
||||
s_logger.debug("delete snapshot on primary storage:");
|
||||
snapshotVO.setState(Snapshot.State.Destroyed);
|
||||
|
|
|
|||
|
|
@ -44,6 +44,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;
|
||||
|
|
@ -117,7 +118,13 @@ public class ObjectInDataStoreManagerImpl implements ObjectInDataStoreManager {
|
|||
ss.setSize(snapshotInfo.getSize()); // this is the virtual size of snapshot in primary storage.
|
||||
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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue