shwstppr commented on code in PR #6643:
URL: https://github.com/apache/cloudstack/pull/6643#discussion_r953667300


##########
engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/vmsnapshot/DefaultVMSnapshotStrategy.java:
##########
@@ -325,12 +329,24 @@ protected void finalizeRevert(VMSnapshotVO vmSnapshot, 
List<VolumeObjectTO> volu
 
     private void updateVolumePath(List<VolumeObjectTO> volumeTOs) {
         for (VolumeObjectTO volume : volumeTOs) {
-            if (volume.getPath() != null) {
-                VolumeVO volumeVO = volumeDao.findById(volume.getId());
+            if (StringUtils.isAllEmpty(volume.getDataStoreUuid(), 
volume.getPath(), volume.getChainInfo())) {
+                continue;
+            }
+            VolumeVO volumeVO = volumeDao.findById(volume.getId());
+            if (StringUtils.isNotEmpty(volume.getDataStoreUuid())) {
+                StoragePool pool = 
primaryDataStoreDao.findPoolByUUID(volume.getDataStoreUuid());
+                if (pool != null && pool.getId() != volumeVO.getPoolId()) {
+                    volumeVO.setPoolId(pool.getId());
+                }
+            }
+            if (StringUtils.isNotEmpty(volume.getPath())) {
                 volumeVO.setPath(volume.getPath());
-                volumeVO.setVmSnapshotChainSize(volume.getSize());
-                volumeDao.persist(volumeVO);
             }
+            if (StringUtils.isNotEmpty(volume.getChainInfo())) {
+                volumeVO.setChainInfo(volume.getChainInfo());
+            }
+            volumeVO.setVmSnapshotChainSize(volume.getSize());
+            volumeDao.persist(volumeVO);

Review Comment:
   @DaanHoogland added unit test



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to