cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GabrielBrascher <...@git.apache.org>
Subject [GitHub] cloudstack pull request #1559: CLOUDSTACK-9280: System VM volumes can be exp...
Date Mon, 17 Oct 2016 14:01:32 GMT
Github user GabrielBrascher commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1559#discussion_r83595364
  
    --- Diff: engine/storage/src/org/apache/cloudstack/storage/endpoint/DefaultEndPointSelector.java
---
    @@ -345,15 +354,34 @@ public EndPoint select(DataObject object, StorageAction action)
{
                 }
             } else if (action == StorageAction.DELETEVOLUME) {
                 VolumeInfo volume = (VolumeInfo)object;
    +            VirtualMachine vm = volume.getAttachedVM();
    +
                 if (volume.getHypervisorType() == Hypervisor.HypervisorType.VMware) {
    -                VirtualMachine vm = volume.getAttachedVM();
                     if (vm != null) {
                         Long hostId = vm.getHostId() != null ? vm.getHostId() : vm.getLastHostId();
                         if (hostId != null) {
                             return getEndPointFromHostId(hostId);
                         }
                     }
                 }
    +
    +            //Handle case where the volume is a volume of an expunging system VM and
there are
    +            //no other system VMs existing in the zone.
    +            if (vm != null) {
    +                VirtualMachine.Type type = volume.getAttachedVM().getType();
    +                if ((type == VirtualMachine.Type.SecondaryStorageVm || type == VirtualMachine.Type.ConsoleProxy)
&&
    +                        (vm.getState() == State.Expunging || vm.getState() == State.Destroyed))
{
    +
    +                    List<SecondaryStorageVmVO> ssvms = ssvmDao.listByZoneId(Role.templateProcessor,
volume.getDataCenterId());
    +                    if (CollectionUtils.isEmpty(ssvms)) {
    +
    +                        s_logger.info("Volume " + volume.getName() + " is attached to
a " + vm.getState() + " " + type + " and zone " +
    +                                        volume.getDataCenterId() + " has no SSVMs.");
    +                        s_logger.info("Volume " + volume.getName() + " will be handled
by dummy endpoint.");
    +                        return DummyEndpoint.getEndpoint();
    +                    }
    +                }
    +            }
    --- End diff --
    
    @ProjectMoon, it might be interesting to extract the code (lines 370 - 384) for a new
method [e.g. `getDummyEndpoint(VolumeInfo volume, VirtualMachine vm)`].
    
    With that, the `select(DataObject object, StorageAction action)` code gets a bit cleaner
and the test case is "isolated" (test for `select(DataObject object, StorageAction action)`
would just require a verify for the `getDummyEndpoint(VolumeInfo volume, VirtualMachine vm)`,
which has its own unit test for its inner logic).
    
    Commented lines (368 and 369) could become Javadoc for the new method.
    
    Thanks.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message