-
Notifications
You must be signed in to change notification settings - Fork 7
Destroyvm also removes volumes #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
DaanHoogland
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good
|
|
||
| import java.net.MalformedURLException; | ||
|
|
||
| import com.cloud.exception.ResourceAllocationException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do these imports need reordering?
|
|
||
| import org.apache.log4j.Logger; | ||
|
|
||
| import com.cloud.event.EventTypes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you want to add to this description whether these are the volumes that will be preserved (or not)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| import org.apache.cloudstack.api.BaseAsyncCmd; | ||
| import org.apache.log4j.Logger; | ||
|
|
||
| import com.cloud.event.EventTypes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no change in imports....
| // under the License. | ||
| package org.apache.cloudstack.api.command.user.volume; | ||
|
|
||
| import org.apache.cloudstack.api.BaseAsyncCmd; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually this file is not changed safe the reordering of imports, please remove it from the PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| } | ||
| } | ||
|
|
||
| public Volume detachVolumesFromVM(long vmId, long volumeId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
detachVolumesFromVM() takes only one volumeId so probably use singular in teh method name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactored to detachVolumeViaDestroyVM(...) to avoid confusion
| return expunge; | ||
| } | ||
|
|
||
| public List<Long> getVolumes() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getVolume(UU)Ids() ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we stopping if one fails?
| } | ||
|
|
||
| for (VolumeVO volume : volumes) { | ||
| _volumeService.deleteVolume(volume.getId(), CallContext.current().getCallingAccount()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
detach here
| } | ||
| } | ||
|
|
||
| detachAndDeleteVolumes(volumes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete detached volumes here
|
|
||
| List<VolumeVO> volumes = new ArrayList<>(); | ||
|
|
||
| if (cmd.getVolumeIds() != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you extract this bit into a method as well?
| } | ||
| return false; | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the below methods can do with unit tests
borisstoyanov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
borisstoyanov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Fixes: #17 Fixes: #18 These dependencies are necessary or eslint will fail with the standard vue.js rule set. The PR also includes fixes for all lint errors. Signed-off-by: Rohit Yadav <[email protected]>

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