CLOUDSTACK-2040 VM with snapshot not getting destroyed during account delation

This commit is contained in:
Mice Xia 2013-04-16 12:38:52 +08:00
parent 7bff1d08f4
commit cbe021b8d2
3 changed files with 16 additions and 11 deletions

View File

@ -19,6 +19,7 @@ package com.cloud.agent.api;
import com.cloud.agent.api.LogLevel.Log4jLevel;
import com.cloud.agent.api.to.S3TO;
import com.cloud.agent.api.to.SwiftTO;
import com.cloud.storage.StoragePool;
/**
* This command encapsulates a primitive operation which enables coalescing the backed up VHD snapshots on the secondary server
@ -78,7 +79,8 @@ public class DeleteSnapshotBackupCommand extends SnapshotCommand {
* @param backupUUID The VHD which has to be deleted
* @param childUUID The child VHD file of the backup whose parent is reset to its grandparent.
*/
public DeleteSnapshotBackupCommand(SwiftTO swift,
public DeleteSnapshotBackupCommand(StoragePool pool,
SwiftTO swift,
S3TO s3,
String secondaryStoragePoolURL,
Long dcId,
@ -86,7 +88,7 @@ public class DeleteSnapshotBackupCommand extends SnapshotCommand {
Long volumeId,
String backupUUID, Boolean all)
{
super(null, secondaryStoragePoolURL, backupUUID, null, dcId, accountId, volumeId);
super(pool, secondaryStoragePoolURL, backupUUID, null, dcId, accountId, volumeId);
setSwift(swift);
this.s3 = s3;
setAll(all);

View File

@ -33,6 +33,8 @@ import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
import org.apache.cloudstack.framework.async.AsyncRpcConext;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.apache.cloudstack.storage.image.ImageDataStoreDriver;
import org.apache.log4j.Logger;
@ -45,8 +47,8 @@ import com.cloud.agent.api.to.SwiftTO;
import com.cloud.host.HostVO;
import com.cloud.host.dao.HostDao;
import com.cloud.storage.RegisterVolumePayload;
import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.SnapshotVO;
import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.VMTemplateStorageResourceAssoc;
import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.VMTemplateZoneVO;
@ -80,6 +82,7 @@ public class AncientImageDataStoreDriverImpl implements ImageDataStoreDriver {
@Inject SnapshotDao snapshotDao;
@Inject AgentManager agentMgr;
@Inject SnapshotManager snapshotMgr;
@Inject PrimaryDataStoreDao primaryDataStoreDao;
@Inject
private SwiftManager _swiftMgr;
@Inject
@ -196,9 +199,10 @@ public class AncientImageDataStoreDriverImpl implements ImageDataStoreDriver {
}
SwiftTO swift = _swiftMgr.getSwiftTO(snapshot.getSwiftId());
S3TO s3 = _s3Mgr.getS3TO();
VolumeVO volume = volumeDao.findById(volumeId);
StoragePoolVO pool = primaryDataStoreDao.findById(volume.getPoolId());
DeleteSnapshotBackupCommand cmd = new DeleteSnapshotBackupCommand(
swift, s3, secondaryStoragePoolUrl, dcId, accountId, volumeId,
pool, swift, s3, secondaryStoragePoolUrl, dcId, accountId, volumeId,
backupOfSnapshot, false);
Answer answer = agentMgr.sendToSSVM(dcId, cmd);

View File

@ -181,9 +181,8 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
private ResourceTagDao _resourceTagDao;
@Inject
private ConfigurationDao _configDao;
@Inject
private VMSnapshotDao _vmSnapshotDao;
@Inject
private PrimaryDataStoreDao _primaryDataStoreDao;
String _name;
@Inject TemplateManager templateMgr;
@ -694,11 +693,11 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
S3TO s3 = _s3Mgr.getS3TO();
checkObjectStorageConfiguration(swift, s3);
StoragePoolVO pool = _primaryDataStoreDao.findById(volume.getPoolId());
if (swift == null && s3 == null) {
for (HostVO ssHost : ssHosts) {
DeleteSnapshotBackupCommand cmd = new DeleteSnapshotBackupCommand(
null, null, ssHost.getStorageUrl(), dcId,
pool,null, null, ssHost.getStorageUrl(), dcId,
accountId, volumeId, "", true);
Answer answer = null;
try {
@ -717,7 +716,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
}
} else {
DeleteSnapshotBackupCommand cmd = new DeleteSnapshotBackupCommand(
swift, s3, "", dcId, accountId, volumeId, "", true);
pool,swift, s3, "", dcId, accountId, volumeId, "", true);
Answer answer = null;
try {
answer = _agentMgr.sendToSSVM(dcId, cmd);