You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2018/05/01 03:57:57 UTC

[GitHub] nitin-maharana commented on a change in pull request #2501: Only perform certain actions with managed storage if the VM is s…

nitin-maharana commented on a change in pull request #2501: Only perform certain actions with managed storage if the VM is s…
URL: https://github.com/apache/cloudstack/pull/2501#discussion_r185162940
 
 

 ##########
 File path: engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
 ##########
 @@ -1349,30 +1349,29 @@ public void prepare(VirtualMachineProfile vm, DeployDestination dest) throws Sto
         StoragePool pool;
         for (VolumeTask task : tasks) {
             if (task.type == VolumeTaskType.NOP) {
-                pool = (StoragePool)dataStoreMgr.getDataStore(task.pool.getId(), DataStoreRole.Primary);
-
-                if (task.pool != null && task.pool.isManaged()) {
-                    long hostId = vm.getVirtualMachine().getHostId();
-                    Host host = _hostDao.findById(hostId);
-
-                    volService.grantAccess(volFactory.getVolume(task.volume.getId()), host, (DataStore)pool);
-                }
-
                 vol = task.volume;
 
-                // For a zone-wide managed storage, it is possible that the VM can be started in another
+                pool = (StoragePool)dataStoreMgr.getDataStore(task.pool.getId(), DataStoreRole.Primary);
+
+                // For zone-wide managed storage, it is possible that the VM can be started in another
                 // cluster. In that case, make sure that the volume is in the right access group.
                 if (pool.isManaged()) {
-                    long oldHostId = vm.getVirtualMachine().getLastHostId();
-                    long hostId = vm.getVirtualMachine().getHostId();
+                    Host lastHost = _hostDao.findById(vm.getVirtualMachine().getLastHostId());
+                    Host host = _hostDao.findById(vm.getVirtualMachine().getHostId());
 
-                    if (oldHostId != hostId) {
-                        Host oldHost = _hostDao.findById(oldHostId);
-                        DataStore storagePool = dataStoreMgr.getDataStore(pool.getId(), DataStoreRole.Primary);
+                    long lastClusterId = lastHost == null || lastHost.getClusterId() == null ? -1 : lastHost.getClusterId();
+                    long clusterId = host == null || host.getClusterId() == null ? -1 : host.getClusterId();
 
-                        storageMgr.removeStoragePoolFromCluster(oldHostId, vol.get_iScsiName(), pool);
+                    if (lastClusterId != clusterId) {
 
 Review comment:
   @mike-tutkowski, I doubt if we need to handle the else part where the target cluster is same as the old one. Where we can put a warning/error that this action cannot be performed on the same cluster different host etc.. Thanks.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services