DaanHoogland commented on code in PR #6643:
URL: https://github.com/apache/cloudstack/pull/6643#discussion_r953450269
##########
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:
More of a general remark than about this piece of code; can these lines be
extracted and tested in unit tests. (extracted is maybe not needed in this
case, but unit tests would be nice)
--
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]