mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
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.
This commit is contained in:
parent
a52ce3628c
commit
f5cebeb71a
@ -1369,6 +1369,20 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
|
|||||||
if (task.type == VolumeTaskType.NOP) {
|
if (task.type == VolumeTaskType.NOP) {
|
||||||
pool = (StoragePool)dataStoreMgr.getDataStore(task.pool.getId(), DataStoreRole.Primary);
|
pool = (StoragePool)dataStoreMgr.getDataStore(task.pool.getId(), DataStoreRole.Primary);
|
||||||
vol = task.volume;
|
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) {
|
} else if (task.type == VolumeTaskType.MIGRATE) {
|
||||||
pool = (StoragePool)dataStoreMgr.getDataStore(task.pool.getId(), DataStoreRole.Primary);
|
pool = (StoragePool)dataStoreMgr.getDataStore(task.pool.getId(), DataStoreRole.Primary);
|
||||||
vol = migrateVolume(task.volume, pool);
|
vol = migrateVolume(task.volume, pool);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user