mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CloudStack fails to migrate VM with volume when there are datadisks attatched (#5410)
* Check if should map volume in createStoragePoolMappingsForVolumes * Invert conditional at internalCanHandle
This commit is contained in:
parent
798d7bebf6
commit
404e264caf
@ -2947,8 +2947,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||||||
* For each one of the volumes we will map it to a storage pool that is available via the target host.
|
* For each one of the volumes we will map it to a storage pool that is available via the target host.
|
||||||
* An exception is thrown if we cannot find a storage pool that is accessible in the target host to migrate the volume to.
|
* An exception is thrown if we cannot find a storage pool that is accessible in the target host to migrate the volume to.
|
||||||
*/
|
*/
|
||||||
protected void createStoragePoolMappingsForVolumes(VirtualMachineProfile profile, DataCenterDeployment plan, Map<Volume, StoragePool> volumeToPoolObjectMap, List<Volume> allVolumes) {
|
protected void createStoragePoolMappingsForVolumes(VirtualMachineProfile profile, DataCenterDeployment plan, Map<Volume, StoragePool> volumeToPoolObjectMap, List<Volume> volumesNotMapped) {
|
||||||
for (Volume volume : allVolumes) {
|
for (Volume volume : volumesNotMapped) {
|
||||||
StoragePoolVO currentPool = _storagePoolDao.findById(volume.getPoolId());
|
StoragePoolVO currentPool = _storagePoolDao.findById(volume.getPoolId());
|
||||||
|
|
||||||
Host targetHost = null;
|
Host targetHost = null;
|
||||||
@ -2958,12 +2958,25 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||||||
executeManagedStorageChecksWhenTargetStoragePoolNotProvided(targetHost, currentPool, volume);
|
executeManagedStorageChecksWhenTargetStoragePoolNotProvided(targetHost, currentPool, volume);
|
||||||
if (ScopeType.HOST.equals(currentPool.getScope()) || isStorageCrossClusterMigration(plan.getClusterId(), currentPool)) {
|
if (ScopeType.HOST.equals(currentPool.getScope()) || isStorageCrossClusterMigration(plan.getClusterId(), currentPool)) {
|
||||||
createVolumeToStoragePoolMappingIfPossible(profile, plan, volumeToPoolObjectMap, volume, currentPool);
|
createVolumeToStoragePoolMappingIfPossible(profile, plan, volumeToPoolObjectMap, volume, currentPool);
|
||||||
} else {
|
} else if (shouldMapVolume(profile, volume, currentPool)){
|
||||||
volumeToPoolObjectMap.put(volume, currentPool);
|
volumeToPoolObjectMap.put(volume, currentPool);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if it should map the volume for a storage pool to migrate.
|
||||||
|
* <br><br>
|
||||||
|
* Some context: VMware migration workflow requires all volumes to be mapped (even if volume stays on its current pool);
|
||||||
|
* however, this is not necessary/desirable for the KVM flow.
|
||||||
|
*/
|
||||||
|
protected boolean shouldMapVolume(VirtualMachineProfile profile, Volume volume, StoragePoolVO currentPool) {
|
||||||
|
boolean isManaged = currentPool.isManaged();
|
||||||
|
boolean isNotKvm = HypervisorType.KVM != profile.getHypervisorType();
|
||||||
|
boolean isNotDatadisk = Type.DATADISK != volume.getVolumeType();
|
||||||
|
return isNotKvm || isNotDatadisk || isManaged;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the managed storage checks for the volumes that the user has not entered a mapping of <volume, storage pool>. The following checks are performed.
|
* Executes the managed storage checks for the volumes that the user has not entered a mapping of <volume, storage pool>. The following checks are performed.
|
||||||
* <ul>
|
* <ul>
|
||||||
|
|||||||
@ -82,21 +82,19 @@ public class KvmNonManagedStorageDataMotionStrategy extends StorageSystemDataMot
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected StrategyPriority internalCanHandle(Map<VolumeInfo, DataStore> volumeMap, Host srcHost, Host destHost) {
|
protected StrategyPriority internalCanHandle(Map<VolumeInfo, DataStore> volumeMap, Host srcHost, Host destHost) {
|
||||||
if (super.internalCanHandle(volumeMap, srcHost, destHost) == StrategyPriority.CANT_HANDLE) {
|
if (super.internalCanHandle(volumeMap, srcHost, destHost) != StrategyPriority.CANT_HANDLE
|
||||||
if (canHandleKVMNonManagedLiveNFSStorageMigration(volumeMap, srcHost, destHost) == StrategyPriority.CANT_HANDLE) {
|
|| canHandleKVMNonManagedLiveNFSStorageMigration(volumeMap, srcHost, destHost) != StrategyPriority.CANT_HANDLE) {
|
||||||
Set<VolumeInfo> volumeInfoSet = volumeMap.keySet();
|
return StrategyPriority.CANT_HANDLE;
|
||||||
|
|
||||||
for (VolumeInfo volumeInfo : volumeInfoSet) {
|
|
||||||
StoragePoolVO storagePoolVO = _storagePoolDao.findById(volumeInfo.getPoolId());
|
|
||||||
|
|
||||||
if (!supportStoragePoolType(storagePoolVO.getPoolType())) {
|
|
||||||
return StrategyPriority.CANT_HANDLE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return StrategyPriority.HYPERVISOR;
|
|
||||||
}
|
}
|
||||||
return StrategyPriority.CANT_HANDLE;
|
|
||||||
|
Set<VolumeInfo> volumeInfoSet = volumeMap.keySet();
|
||||||
|
for (VolumeInfo volumeInfo : volumeInfoSet) {
|
||||||
|
StoragePoolVO storagePoolVO = _storagePoolDao.findById(volumeInfo.getPoolId());
|
||||||
|
if (!supportStoragePoolType(storagePoolVO.getPoolType())) {
|
||||||
|
return StrategyPriority.CANT_HANDLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return StrategyPriority.HYPERVISOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user