Destroyvm also removes volumes#18
Destroyvm also removes volumes#18houthuis wants to merge 15 commits intomastershapeblue/cloudstack:masterfrom destroyvm-also-removes-volumesshapeblue/cloudstack:destroyvm-also-removes-volumesCopy head branch name to clipboard
Conversation
|
@houthuis seems ypiu have conflicts, can you resolve those , please? |
…hapeblue/cloudstack into destroyvm-also-removes-volumes
… destroyvm-also-removes-volumes # Conflicts: # api/src/main/java/org/apache/cloudstack/api/ApiConstants.java # server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java
|
|
||
| import java.net.MalformedURLException; | ||
|
|
||
| import com.cloud.exception.ResourceAllocationException; |
There was a problem hiding this comment.
why do these imports need reordering?
|
|
||
| import org.apache.log4j.Logger; | ||
|
|
||
| import com.cloud.event.EventTypes; |
There was a problem hiding this comment.
no reason to reorder these imports is there?
| type = CommandType.LIST, | ||
| collectionType = CommandType.UUID, | ||
| entityType = VolumeResponse.class, | ||
| description = "Comma separated list of volume UUIDs", |
There was a problem hiding this comment.
I think you want to add to this description whether these are the volumes that will be preserved (or not)
| import org.apache.cloudstack.api.BaseAsyncCmd; | ||
| import org.apache.log4j.Logger; | ||
|
|
||
| import com.cloud.event.EventTypes; |
| // under the License. | ||
| package org.apache.cloudstack.api.command.user.volume; | ||
|
|
||
| import org.apache.cloudstack.api.BaseAsyncCmd; |
There was a problem hiding this comment.
actually this file is not changed safe the reordering of imports, please remove it from the PR
| } | ||
| } | ||
|
|
||
| public Volume detachVolumesFromVM(long vmId, long volumeId) { |
There was a problem hiding this comment.
detachVolumesFromVM() takes only one volumeId so probably use singular in teh method name
There was a problem hiding this comment.
refactored to detachVolumeViaDestroyVM(...) to avoid confusion
| return expunge; | ||
| } | ||
|
|
||
| public List<Long> getVolumes() { |
There was a problem hiding this comment.
done, renamed field + api parameter
| } | ||
| s_logger.debug("Found no ongoing snapshots on volume of type ROOT, for the vm with id " + vmId); | ||
|
|
||
| List<VolumeVO> volumes = new ArrayList<>(); |
There was a problem hiding this comment.
It would seem that you would first want to destroy the VM and only after try the volumes
| private void detachAndDeleteVolumes(List<VolumeVO> volumes) { | ||
|
|
||
| for (VolumeVO volume : volumes) { | ||
| _volumeService.detachVolumesFromVM(volume.getInstanceId(), volume.getId()); |
There was a problem hiding this comment.
are we stopping if one fails?
| } | ||
|
|
||
| for (VolumeVO volume : volumes) { | ||
| _volumeService.deleteVolume(volume.getId(), CallContext.current().getCallingAccount()); |
There was a problem hiding this comment.
same here: are we stopping if one fails?
| collectionType = CommandType.UUID, | ||
| entityType = VolumeResponse.class, | ||
| description = "Comma separated list of volume UUIDs", | ||
| description = "Comma separated list of volume UUIDs that will be deleted", |
There was a problem hiding this comment.
"Comma separated list of UUIDs for volumes that will be deleted" ?
| } | ||
|
|
||
| public Volume detachVolumesFromVM(long vmId, long volumeId) { | ||
| public Volume detachVolumeViaDestroyVM(long vmId, long volumeId) { |
There was a problem hiding this comment.
Why would this be specific to destroy vm ? isn't it just a detach method and didn't it already exist?
| } | ||
| } | ||
|
|
||
| public Volume detachVolumeViaDestroyVM(long vmId, long volumeId) { |
There was a problem hiding this comment.
couple of questions here:
Is this really public? it may a only be called as part of destroy volume!
How different is it really (even being consequential) from regular detachVolumeFromVM? it should at least also fire a detach event to keep usage data in check.
|
|
||
| checkForUnattachedVolumes(vmId, volumes); | ||
| validateVolumes(volumes); | ||
|
|
| } | ||
| } | ||
|
|
||
| detachAndDeleteVolumes(volumes); |
There was a problem hiding this comment.
delete detached volumes here
|
|
||
| List<VolumeVO> volumes = new ArrayList<>(); | ||
|
|
||
| if (cmd.getVolumeIds() != null) { |
There was a problem hiding this comment.
can you extract this bit into a method as well?
| } | ||
| return false; | ||
| } | ||
|
|
There was a problem hiding this comment.
the below methods can do with unit tests
borisstoyanov
left a comment
There was a problem hiding this comment.
LGTM, all remarks from my side has been addressed.
|
@houthuis I think you're in position to submit this to community now |
|
@dhlaluku can you pick this up, resubmit the changes? |
|
@rhtyd I am working on it, I will submit a new PR when it's complete since I can't reopen this one. |
* Explicitly controlling VMware VM hardware version * Fix unit test

Description
TBC
Types of changes
GitHub Issue/PRs
Screenshots (if appropriate):
How Has This Been Tested?
Checklist:
Testing