Compare commits

...

3 Commits

Author SHA1 Message Date
Abhishek Kumar 5a06ae7c64
Merge e12a3f9c00 into cd5bb09d0d 2026-01-22 09:59:54 +00:00
Abhishek Kumar e12a3f9c00
Merge branch '4.20' into fix-vmsnap-delete 2025-12-24 14:03:00 +05:30
Abhishek Kumar 92f7a5754f server: delete errored instance snapshot from db when no strategy
DB entries for instance snapshot are created when no strategy is found.
When deleting such entries later, again error is seen. Therefore, it is
better to remove the entry immediately.

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
2025-09-01 15:10:33 +05:30
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);
}
}