This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch 4.11
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.11 by this push:
new e471a46 managed-storage: handle VM start in a new cluster on
different host (#2656)
e471a46 is described below
commit e471a46a05b623ffc5cc5f950238b3525bc1c2e9
Author: Mike Tutkowski <[email protected]>
AuthorDate: Mon May 21 04:52:33 2018 -0600
managed-storage: handle VM start in a new cluster on different host (#2656)
Example: A VM that uses managed storage is stopped. The VM is then started
on a different host in the same cluster. The Start operation fails.
To get around this issue, you must either start the VM up on the same host
or on a host in a different cluster.
The reason is due to a slightly erroneous check in
VolumeOrchestrator.prepare.
To solve this issue, we should be checking if the cluster ID changes, not
if the host ID changes.
---
.../engine/orchestration/VolumeOrchestrator.java | 33 +++++++++++-----------
1 file changed, 16 insertions(+), 17 deletions(-)
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 a9035d4..e5e0bbf 100644
---
a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
+++
b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
@@ -1344,30 +1344,29 @@ public class VolumeOrchestrator extends ManagerBase
implements VolumeOrchestrati
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) {
+ if (lastHost != null) {
+
storageMgr.removeStoragePoolFromCluster(lastHost.getId(), vol.get_iScsiName(),
pool);
+
+ DataStore storagePool =
dataStoreMgr.getDataStore(pool.getId(), DataStoreRole.Primary);
+
+
volService.revokeAccess(volFactory.getVolume(vol.getId()), lastHost,
storagePool);
+ }
-
volService.revokeAccess(volFactory.getVolume(vol.getId()), oldHost,
storagePool);
+
volService.grantAccess(volFactory.getVolume(vol.getId()), host,
(DataStore)pool);
}
}
} else if (task.type == VolumeTaskType.MIGRATE) {
--
To stop receiving notification emails like this one, please contact
[email protected].