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:
Gabriel Beims Bräscher 2021-10-08 03:20:37 -03:00 committed by GitHub
parent 798d7bebf6
commit 404e264caf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 17 deletions

View File

@ -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.
* 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) {
for (Volume volume : allVolumes) {
protected void createStoragePoolMappingsForVolumes(VirtualMachineProfile profile, DataCenterDeployment plan, Map<Volume, StoragePool> volumeToPoolObjectMap, List<Volume> volumesNotMapped) {
for (Volume volume : volumesNotMapped) {
StoragePoolVO currentPool = _storagePoolDao.findById(volume.getPoolId());
Host targetHost = null;
@ -2958,12 +2958,25 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
executeManagedStorageChecksWhenTargetStoragePoolNotProvided(targetHost, currentPool, volume);
if (ScopeType.HOST.equals(currentPool.getScope()) || isStorageCrossClusterMigration(plan.getClusterId(), currentPool)) {
createVolumeToStoragePoolMappingIfPossible(profile, plan, volumeToPoolObjectMap, volume, currentPool);
} else {
} else if (shouldMapVolume(profile, 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.
* <ul>

View File

@ -82,21 +82,19 @@ public class KvmNonManagedStorageDataMotionStrategy extends StorageSystemDataMot
*/
@Override
protected StrategyPriority internalCanHandle(Map<VolumeInfo, DataStore> volumeMap, Host srcHost, Host destHost) {
if (super.internalCanHandle(volumeMap, srcHost, destHost) == StrategyPriority.CANT_HANDLE) {
if (canHandleKVMNonManagedLiveNFSStorageMigration(volumeMap, srcHost, destHost) == 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;
if (super.internalCanHandle(volumeMap, srcHost, destHost) != StrategyPriority.CANT_HANDLE
|| canHandleKVMNonManagedLiveNFSStorageMigration(volumeMap, srcHost, destHost) != StrategyPriority.CANT_HANDLE) {
return StrategyPriority.CANT_HANDLE;
}
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;
}
/**