You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2017/09/01 19:10:48 UTC

[cloudstack] branch master updated: CLOUDSTACK-10061: When starting a VM, make sure it is attached to correct VAG when using managed storage (#2253)

This is an automated email from the ASF dual-hosted git repository.

bhaisaab pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/master by this push:
     new f5cebeb  CLOUDSTACK-10061: When starting a VM, make sure it is attached to correct VAG when using managed storage (#2253)
f5cebeb is described below

commit f5cebeb71af1ce097c20fd4d3b3ba6f31e28cbfd
Author: Syed Mushtaq Ahmed <sy...@gmail.com>
AuthorDate: Fri Sep 1 15:10:44 2017 -0400

    CLOUDSTACK-10061: When starting a VM, make sure it is attached to correct VAG when using managed storage (#2253)
    
    This can happen when you stop a VM in one cluster and start a VM in another cluster. When the VM starts in a new cluster, we don't add a new VAG and hence it fails to start. This PR ensures that we call grantAccess to the VM that gets started which will fix the access issue.
---
 .../engine/orchestration/VolumeOrchestrator.java           | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
index 018c62e..c039a2f 100644
--- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
@@ -1369,6 +1369,20 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
             if (task.type == VolumeTaskType.NOP) {
                 pool = (StoragePool)dataStoreMgr.getDataStore(task.pool.getId(), DataStoreRole.Primary);
                 vol = task.volume;
+                // For a zone-wide managed storage, it is possible that the VM can be started in another
+                // cluster. In that case make sure that the volume in in the right access group cluster.
+                if (pool.isManaged()) {
+                    long oldHostId = vm.getVirtualMachine().getLastHostId();
+                    long hostId = vm.getVirtualMachine().getHostId();
+                    if (oldHostId != hostId) {
+                        Host oldHost = _hostDao.findById(oldHostId);
+                        Host host = _hostDao.findById(hostId);
+                        DataStore storagePool = dataStoreMgr.getDataStore(pool.getId(), DataStoreRole.Primary);
+
+                        volService.revokeAccess(volFactory.getVolume(vol.getId()), oldHost, storagePool);
+                        volService.grantAccess(volFactory.getVolume(vol.getId()), host, storagePool);
+                    }
+                }
             } else if (task.type == VolumeTaskType.MIGRATE) {
                 pool = (StoragePool)dataStoreMgr.getDataStore(task.pool.getId(), DataStoreRole.Primary);
                 vol = migrateVolume(task.volume, pool);

-- 
To stop receiving notification emails like this one, please contact
['"commits@cloudstack.apache.org" <co...@cloudstack.apache.org>'].