mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-4318: clean up snapshot stored in staging area, after backup snapshot to object store
This commit is contained in:
parent
374de76dae
commit
dd6b245221
|
|
@ -563,12 +563,13 @@ public class KVMStorageProcessor implements StorageProcessor {
|
|||
String srcSnapshotDir = srcPath.substring(0, index);
|
||||
String srcFileName = srcPath.substring(index + 1);
|
||||
KVMStoragePool srcStorePool = null;
|
||||
File srcFile = null;
|
||||
try {
|
||||
srcStorePool = storagePoolMgr.getStoragePoolByURI(srcStore.getUrl() + File.separator + srcSnapshotDir);
|
||||
if (srcStorePool == null) {
|
||||
return new CopyCmdAnswer("Can't get store:" + srcStore.getUrl());
|
||||
}
|
||||
File srcFile = new File(srcStorePool.getLocalPath() + File.separator + srcFileName);
|
||||
srcFile = new File(srcStorePool.getLocalPath() + File.separator + srcFileName);
|
||||
if (!srcFile.exists()) {
|
||||
return new CopyCmdAnswer("Can't find src file: " + srcPath);
|
||||
}
|
||||
|
|
@ -582,8 +583,15 @@ public class KVMStorageProcessor implements StorageProcessor {
|
|||
newSnapshot.setPath(destPath);
|
||||
return new CopyCmdAnswer(newSnapshot);
|
||||
} finally {
|
||||
if (srcStorePool != null) {
|
||||
srcStorePool.delete();
|
||||
try {
|
||||
if (srcFile != null) {
|
||||
srcFile.delete();
|
||||
}
|
||||
if (srcStorePool != null) {
|
||||
srcStorePool.delete();
|
||||
}
|
||||
} catch(Exception e) {
|
||||
s_logger.debug("Failed to clean up:", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,14 +29,16 @@ import com.cloud.hypervisor.vmware.manager.VmwareStorageManager;
|
|||
import com.cloud.storage.DataStoreRole;
|
||||
import org.apache.cloudstack.storage.command.CopyCmdAnswer;
|
||||
import org.apache.cloudstack.storage.command.CopyCommand;
|
||||
import org.apache.cloudstack.storage.command.DeleteCommand;
|
||||
import org.apache.cloudstack.storage.to.SnapshotObjectTO;
|
||||
import org.apache.cloudstack.storage.to.TemplateObjectTO;
|
||||
import org.apache.cloudstack.storage.to.VolumeObjectTO;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class VmwareStorageSubsystemCommandHandler extends StorageSubsystemCommandHandlerBase {
|
||||
|
||||
private static final Logger s_logger = Logger.getLogger(VmwareStorageSubsystemCommandHandler.class);
|
||||
private VmwareStorageManager storageManager;
|
||||
private PremiumSecondaryStorageResource storageResource;
|
||||
|
||||
|
|
@ -125,7 +127,17 @@ public class VmwareStorageSubsystemCommandHandler extends StorageSubsystemComman
|
|||
newSnapshot.setPath(newSnapshot.getPath() + ".ova");
|
||||
newSnapshot.setDataStore(cmd.getCacheTO().getDataStore());
|
||||
CopyCommand newCmd = new CopyCommand(newSnapshot, destData, cmd.getWait(), cmd.executeInSequence());
|
||||
return storageResource.defaultAction(newCmd);
|
||||
Answer result = storageResource.defaultAction(newCmd);
|
||||
|
||||
//clean up data on staging area
|
||||
try {
|
||||
newSnapshot.setPath(path);
|
||||
DeleteCommand deleteCommand = new DeleteCommand(newSnapshot);
|
||||
storageResource.defaultAction(deleteCommand);
|
||||
} catch (Exception e) {
|
||||
s_logger.debug("Failed to clean up staging area:", e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue