mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-7947:
double check if parent snapshot is removed or not, when creating new snapshot Reviewed-by: Min
This commit is contained in:
parent
2ccecce515
commit
4140811549
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue