-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
CLOUDSTACK-9280: Allow system VM volumes to be expunged if no system VMs are remaining. #1406
Conversation
How have you been able to test this one? |
Tests were performed using a running environment. Deploy a zone, then delete the hosts in the zone and make sure there are no system VMs remaining. Wait for the cleanup thread to run. Without this fix, the volumes will not be deleted and it will log errors about missing endpoints/SSVM being down. With it, the volumes will be expunged. The zone cannot be deleted otherwise. @wido part of this pull request is to figure out what unit tests we can add. This change is quite invasive in my opinion, so we want to make sure all possible cases are covered. |
(vm.getState() == State.Expunging || vm.getState() == State.Destroyed)) { | ||
|
||
List<SecondaryStorageVmVO> ssvms = ssvmDao.listByZoneId(Role.templateProcessor, volume.getDataCenterId()); | ||
if (ssvms == null || ssvms.isEmpty()) { |
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.
@ProjectMoon As a sujestion, this conditional (ssvms == null || ssvms.isEmpty()) can be done using the Apache CollectionUtils.isEmpty method (http://commons.apache.org/proper/commons-collections/javadocs/api-release/org/apache/commons/collections4/CollectionUtils.html#isEmpty%28java.util.Collection%29). It is a null safe verification if the List is empty.
@GabrielBrascher added CollectionUtils.isEmpty. Any ideas on unit test-ability? |
@@ -92,7 +92,7 @@ public static VolumeObject getVolumeObject(DataStore dataStore, VolumeVO volumeV | |||
public String getAttachedVmName() { | |||
Long vmId = volumeVO.getInstanceId(); | |||
if (vmId != null) { | |||
VMInstanceVO vm = vmInstanceDao.findById(vmId); | |||
VMInstanceVO vm = vmInstanceDao.findByIdIncludingRemoved(vmId); |
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.
@ProjectMoon I couldn't find the "findByIdIncludingRemoved" method
(https://github.com/apache/cloudstack/blob/master/engine/schema/src/com/cloud/vm/dao/VMInstanceDao.java).
Am I missing something?
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.
Sorry @ProjectMoon, my mistake (it is all right, the method is implemented on GenericDao).
ACS CI BVT RunSumarry: The follwing tests have known issues Link to logs Folder (search by build_no): https://www.dropbox.com/sh/yj3wnzbceo9uef2/AAB6u-Iap-xztdm6jHX9SjPja?dl=0 Failed tests:
Skipped tests: Passed test suits: |
Is this output from the new automated system, or were these manually run? At first glance some of the failed tests don't seem related to this change (some definitely do seem related), though since the change is quite invasive, I suppose anything is possible. |
This commit adds a special SSVM endpoint which simply returns true for all operations sent to it, without actually doing anything. This allows for destroyed volumes of system VMs to be expunged when there are no hosts (and thus no system VMs) remaining to handle the volume destruction.
another one against 4.6. how should we be handling this? |
The current workflow, as I understand it, is that the oldest supported release branch is for bug fixes (which are then forward-merged), and any new features go on master. |
Yes exactly, but the oldest supported branch right now is 4.7. |
@ProjectMoon open PR against 4.7, this enhancement is feature-ish; so I would say open against master. Thanks |
@ProjectMoon can you reopen this against at least 4.7, maybe even master. Thanks... |
Have opened #1559 against master. |
This pull request is our proposed fix for https://issues.apache.org/jira/browse/CLOUDSTACK-9280. I added a new special SSVM endpoint that happily accepts any command given to it. This endpoint is used in only a very specific scenario:
The volume's VM is in state destroyed or expunging, but the volume still lingers.
The volume's VM is a system VM (SSVM or console proxy).
There are no secondary storage machines existing in the volume's zone.
This necessitated a small change to VolumeObject which allows it to find removed VMs (findByIdIncludingRemoved). The main part of the work is in the DefaultEndpointSelector.
We would like some thorough review of this PR as well as what tests to create/run. I'm not sure if the scope of this fix will lead to unintentional behavior changes in other scenarios.