This commit is contained in:
Abhishek Kumar 2026-01-22 15:13:22 +01:00 committed by GitHub
commit 7c97c202ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 1 deletions

View File

@ -135,6 +135,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 Instance Snapshot strategy for instance snapshot";
@Inject
VMInstanceDao _vmInstanceDao;
@Inject ServiceOfferingDetailsDao _serviceOfferingDetailsDao;
@ -501,7 +503,7 @@ public class VMSnapshotManagerImpl extends MutualExclusiveIdsManagerBase impleme
VMSnapshotStrategy snapshotStrategy = storageStrategyFactory.getVmSnapshotStrategy(vmSnapshot);
if (snapshotStrategy == null) {
throw new CloudRuntimeException(String.format("Can't find Instance Snapshot strategy for vmsnapshot: %s", vmSnapshot));
throw new CloudRuntimeException(String.format("%s: %s", ERROR_STRATEGY_NOT_FOUND, vmSnapshot));
}
return snapshotStrategy;
@ -596,6 +598,13 @@ public class VMSnapshotManagerImpl extends MutualExclusiveIdsManagerBase impleme
} catch (Exception e) {
String errMsg = String.format("Failed to create Instance 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);
}
}