sureshanaparti commented on a change in pull request #4307:
URL: https://github.com/apache/cloudstack/pull/4307#discussion_r529209046



##########
File path: server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
##########
@@ -2899,14 +2899,20 @@ public UserVm destroyVm(DestroyVMCmd cmd) throws 
ResourceUnavailableException, C
         }
         s_logger.debug("Found no ongoing snapshots on volume of type ROOT, for 
the vm with id " + vmId);
 
-        List<VolumeVO> volumes = getVolumesFromIds(cmd);
+        List<VolumeVO> volumesToBeDeleted = getVolumesFromIds(cmd);
 
-        checkForUnattachedVolumes(vmId, volumes);
-        validateVolumes(volumes);
+        checkForUnattachedVolumes(vmId, volumesToBeDeleted);
+        validateVolumes(volumesToBeDeleted);
 
         stopVirtualMachine(vmId, VmDestroyForcestop.value());
 
-        detachVolumesFromVm(volumes);
+        if (vm.getHypervisorType() == HypervisorType.VMware) {
+            List<VolumeVO> allVolumes = _volsDao.findByInstance(vm.getId());
+            allVolumes.removeIf(vol -> vol.getVolumeType() == 
Volume.Type.ROOT);
+            detachVolumesFromVm(allVolumes);
+        } else {
+            detachVolumesFromVm(volumesToBeDeleted);
+        }

Review comment:
       these changes are reverted in the PR 
https://github.com/apache/cloudstack/pull/4493 , as the data disks (which are 
not to be deleted) are being detached on destroy VM, which is breaking the 
existing behavior.




----------------------------------------------------------------
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.

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


Reply via email to