FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: handle failed storage VM snapshot cleanup in StorageVMSnapshotStrategy by waterWang · Pull Request #13976 · apache/cloudstack · GitHub

Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .java  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,10 @@ public boolean revertVMSnapshot(VMSnapshot vmSnapshot) {
@Override
public StrategyPriority canHandle(VMSnapshot vmSnapshot) {
UserVmVO userVm = userVmDao.findById(vmSnapshot.getVmId());
if (!VMSnapshot.State.Allocated.equals(vmSnapshot.getState())) {
// Failed (Error) storage snapshots do not have the STORAGE_SNAPSHOT detail persisted, as the
// details are removed during the creation rollback. They still need to be handled by this
// strategy so their database records can be cleaned up without requiring access to the VM.
if (!VMSnapshot.State.Allocated.equals(vmSnapshot.getState()) && !VMSnapshot.State.Error.equals(vmSnapshot.getState())) {
List<VMSnapshotDetailsVO> vmSnapshotDetails = vmSnapshotDetailsDao.findDetails(vmSnapshot.getId(), STORAGE_SNAPSHOT);
if (CollectionUtils.isEmpty(vmSnapshotDetails)) {
return StrategyPriority.CANT_HANDLE;
Expand All @@ -364,6 +367,19 @@ public StrategyPriority canHandle(VMSnapshot vmSnapshot) {
return StrategyPriority.CANT_HANDLE;
}

@Override
public boolean deleteVMSnapshot(VMSnapshot vmSnapshot) {
// A failed (Error) storage snapshot has no underlying storage snapshot to delete: the
// takeVMSnapshot rollback already removed any snapshots that were created before the
// failure. Sending DeleteVMSnapshotCommand to the hypervisor would fail for a stopped VM
// with RAW/RBD volumes because no libvirt domain exists. Clean up the database record
// directly instead.
if (VMSnapshot.State.Error.equals(vmSnapshot.getState())) {
return deleteVMSnapshotFromDB(vmSnapshot, false);
}
return super.deleteVMSnapshot(vmSnapshot);
}

@Override
public StrategyPriority canHandle(Long vmId, Long rootPoolId, boolean snapshotMemory) {
UserVmVO vm = userVmDao.findById(vmId);
Expand Down

Back | FazBrowse Home | New Git URL