storage: Fixed null pointer (#4130)

Fixes #4090

When trying to migrate a VM across 2 clusters, if a snapshot has been deleted and garbage collection has run to update the removed field, it is not possible to migrate the instance due to a null pointer.
This commit is contained in:
Spaceman1984 2020-06-15 06:24:22 +02:00 committed by GitHub
parent 8b234bd14f
commit 6a683dcf77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -73,6 +73,9 @@ public class SnapshotDataFactoryImpl implements SnapshotDataFactory {
for (SnapshotDataStoreVO snapshotDataStoreVO : allSnapshotsFromVolumeAndDataStore) {
DataStore store = storeMgr.getDataStore(snapshotDataStoreVO.getDataStoreId(), role);
SnapshotVO snapshot = snapshotDao.findById(snapshotDataStoreVO.getSnapshotId());
if (snapshot == null){ //snapshot may have been removed;
continue;
}
SnapshotObject info = SnapshotObject.getSnapshotObject(snapshot, store);
infos.add(info);