Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ public class VMSnapshotManagerImpl extends MutualExclusiveIdsManagerBase impleme

public static final String VM_WORK_JOB_HANDLER = VMSnapshotManagerImpl.class.getSimpleName();

private static final String ERROR_STRATEGY_NOT_FOUND = "can't find vm snapshot strategy for instance snapshot";

@Inject
VMInstanceDao _vmInstanceDao;
@Inject ServiceOfferingDetailsDao _serviceOfferingDetailsDao;
Expand Down Expand Up @@ -500,7 +502,7 @@ private VMSnapshotStrategy findVMSnapshotStrategy(VMSnapshot vmSnapshot) {
VMSnapshotStrategy snapshotStrategy = storageStrategyFactory.getVmSnapshotStrategy(vmSnapshot);

if (snapshotStrategy == null) {
throw new CloudRuntimeException(String.format("can't find vm snapshot strategy for vmsnapshot: %s", vmSnapshot));
throw new CloudRuntimeException(String.format("%s: %s", ERROR_STRATEGY_NOT_FOUND, vmSnapshot));
}

return snapshotStrategy;
Expand Down Expand Up @@ -595,6 +597,13 @@ private VMSnapshot orchestrateCreateVMSnapshot(Long vmId, Long vmSnapshotId, Boo
} catch (Exception e) {
String errMsg = String.format("Failed to create vm snapshot: [%s] due to: %s", vmSnapshot, e.getMessage());
logger.debug(errMsg, e);
if (e instanceof CloudRuntimeException) {
CloudRuntimeException cre = (CloudRuntimeException)e;
if (cre.getMessage().startsWith(ERROR_STRATEGY_NOT_FOUND) && VMSnapshot.State.Error.equals(vmSnapshot.getState())) {
logger.debug("No instance snapshot strategy found for {}, remove it from DB", vmSnapshot);
_vmSnapshotDao.remove(vmSnapshot.getId());
}
}
throw new CloudRuntimeException(errMsg, e);
}
}
Expand Down
Loading