Skip to content

Commit 2f2d741

Browse files
committed
fix migration from local to nfs
1 parent 44aa08c commit 2f2d741

File tree

2 files changed

+2
-86
lines changed

2 files changed

+2
-86
lines changed

engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,8 +1976,8 @@ public void copyAsync(Map<VolumeInfo, DataStore> volumeDataStoreMap, VirtualMach
19761976

19771977
MigrateCommand.MigrateDiskInfo migrateDiskInfo;
19781978

1979-
boolean isNonManagedNfsToNfsOrSharedMountPointToNfs = supportStoragePoolType(sourceStoragePool.getPoolType()) && destStoragePool.getPoolType() == StoragePoolType.NetworkFilesystem && !managedStorageDestination;
1980-
if (isNonManagedNfsToNfsOrSharedMountPointToNfs) {
1979+
boolean isNonManagedToNfs = supportStoragePoolType(sourceStoragePool.getPoolType(), StoragePoolType.Filesystem) && destStoragePool.getPoolType() == StoragePoolType.NetworkFilesystem && !managedStorageDestination;
1980+
if (isNonManagedToNfs) {
19811981
migrateDiskInfo = new MigrateCommand.MigrateDiskInfo(srcVolumeInfo.getPath(),
19821982
MigrateCommand.MigrateDiskInfo.DiskType.FILE,
19831983
MigrateCommand.MigrateDiskInfo.DriverType.QCOW2,
@@ -2385,26 +2385,10 @@ protected void verifyLiveMigrationForKVM(Map<VolumeInfo, DataStore> volumeDataSt
23852385
} else if (storageTypeConsistency != destStoragePoolVO.isManaged()) {
23862386
throw new CloudRuntimeException("Destination storage pools must be either all managed or all not managed");
23872387
}
2388-
2389-
addSourcePoolToPoolsMap(sourcePools, srcStoragePoolVO, destStoragePoolVO);
23902388
}
23912389
verifyDestinationStorage(sourcePools, destHost);
23922390
}
23932391

2394-
/**
2395-
* Adds source storage pool to the migration map if the destination pool is not managed and it is NFS.
2396-
*/
2397-
protected void addSourcePoolToPoolsMap(Map<String, Storage.StoragePoolType> sourcePools, StoragePoolVO srcStoragePoolVO, StoragePoolVO destStoragePoolVO) {
2398-
if (destStoragePoolVO.isManaged() || !StoragePoolType.NetworkFilesystem.equals(destStoragePoolVO.getPoolType())) {
2399-
LOGGER.trace(String.format("Skipping adding source pool [%s] to map due to destination pool [%s] is managed or not NFS.", srcStoragePoolVO, destStoragePoolVO));
2400-
return;
2401-
}
2402-
2403-
String sourceStoragePoolUuid = srcStoragePoolVO.getUuid();
2404-
if (!sourcePools.containsKey(sourceStoragePoolUuid)) {
2405-
sourcePools.put(sourceStoragePoolUuid, srcStoragePoolVO.getPoolType());
2406-
}
2407-
}
24082392

24092393
/**
24102394
* Perform storage validation on destination host for KVM live storage migrations.

engine/storage/datamotion/src/test/java/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategyTest.java

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -372,72 +372,4 @@ public void validateIsStoragePoolTypeInListReturnsFalse() {
372372

373373
assertFalse(strategy.isStoragePoolTypeInList(StoragePoolType.SharedMountPoint, listTypes));
374374
}
375-
376-
@Test
377-
public void validateAddSourcePoolToPoolsMapDestinationPoolIsManaged() {
378-
Mockito.doReturn(true).when(destinationStoragePoolVoMock).isManaged();
379-
strategy.addSourcePoolToPoolsMap(mapStringStoragePoolTypeMock, sourceStoragePoolVoMock, destinationStoragePoolVoMock);
380-
381-
Mockito.verify(destinationStoragePoolVoMock).isManaged();
382-
Mockito.verifyNoMoreInteractions(mapStringStoragePoolTypeMock, sourceStoragePoolVoMock, destinationStoragePoolVoMock);
383-
}
384-
385-
@Test
386-
public void validateAddSourcePoolToPoolsMapDestinationPoolIsNotNFS() {
387-
List<StoragePoolType> storagePoolTypes = new LinkedList<>(Arrays.asList(StoragePoolType.values()));
388-
storagePoolTypes.remove(StoragePoolType.NetworkFilesystem);
389-
390-
Mockito.doReturn(false).when(destinationStoragePoolVoMock).isManaged();
391-
storagePoolTypes.forEach(poolType -> {
392-
Mockito.doReturn(poolType).when(destinationStoragePoolVoMock).getPoolType();
393-
strategy.addSourcePoolToPoolsMap(mapStringStoragePoolTypeMock, sourceStoragePoolVoMock, destinationStoragePoolVoMock);
394-
});
395-
396-
VerificationMode times = Mockito.times(storagePoolTypes.size());
397-
Mockito.verify(destinationStoragePoolVoMock, times).isManaged();
398-
Mockito.verify(destinationStoragePoolVoMock, times).getPoolType();
399-
Mockito.verifyNoMoreInteractions(mapStringStoragePoolTypeMock, sourceStoragePoolVoMock, destinationStoragePoolVoMock);
400-
}
401-
402-
@Test
403-
public void validateAddSourcePoolToPoolsMapMapContainsKey() {
404-
Mockito.doReturn(false).when(destinationStoragePoolVoMock).isManaged();
405-
Mockito.doReturn(StoragePoolType.NetworkFilesystem).when(destinationStoragePoolVoMock).getPoolType();
406-
Mockito.doReturn("").when(sourceStoragePoolVoMock).getUuid();
407-
Mockito.doReturn(true).when(mapStringStoragePoolTypeMock).containsKey(Mockito.anyString());
408-
strategy.addSourcePoolToPoolsMap(mapStringStoragePoolTypeMock, sourceStoragePoolVoMock, destinationStoragePoolVoMock);
409-
410-
Mockito.verify(destinationStoragePoolVoMock, never()).getScope();
411-
Mockito.verify(destinationStoragePoolVoMock).isManaged();
412-
Mockito.verify(destinationStoragePoolVoMock).getPoolType();
413-
Mockito.verify(sourceStoragePoolVoMock).getUuid();
414-
Mockito.verify(mapStringStoragePoolTypeMock).containsKey(Mockito.anyString());
415-
Mockito.verifyNoMoreInteractions(mapStringStoragePoolTypeMock, sourceStoragePoolVoMock, destinationStoragePoolVoMock);
416-
}
417-
418-
@Test
419-
public void validateAddSourcePoolToPoolsMapMapDoesNotContainsKey() {
420-
List<StoragePoolType> storagePoolTypes = new LinkedList<>(Arrays.asList(StoragePoolType.values()));
421-
422-
Mockito.doReturn(false).when(destinationStoragePoolVoMock).isManaged();
423-
Mockito.doReturn(StoragePoolType.NetworkFilesystem).when(destinationStoragePoolVoMock).getPoolType();
424-
Mockito.doReturn("").when(sourceStoragePoolVoMock).getUuid();
425-
Mockito.doReturn(false).when(mapStringStoragePoolTypeMock).containsKey(Mockito.anyString());
426-
Mockito.doReturn(null).when(mapStringStoragePoolTypeMock).put(Mockito.anyString(), Mockito.any());
427-
428-
storagePoolTypes.forEach(poolType -> {
429-
Mockito.doReturn(poolType).when(sourceStoragePoolVoMock).getPoolType();
430-
strategy.addSourcePoolToPoolsMap(mapStringStoragePoolTypeMock, sourceStoragePoolVoMock, destinationStoragePoolVoMock);
431-
});
432-
433-
VerificationMode times = Mockito.times(storagePoolTypes.size());
434-
Mockito.verify(destinationStoragePoolVoMock, never()).getScope();
435-
Mockito.verify(destinationStoragePoolVoMock, times).isManaged();
436-
Mockito.verify(destinationStoragePoolVoMock, times).getPoolType();
437-
Mockito.verify(sourceStoragePoolVoMock, times).getUuid();
438-
Mockito.verify(mapStringStoragePoolTypeMock, times).containsKey(Mockito.anyString());
439-
Mockito.verify(sourceStoragePoolVoMock, times).getPoolType();
440-
Mockito.verify(mapStringStoragePoolTypeMock, times).put(Mockito.anyString(), Mockito.any());
441-
Mockito.verifyNoMoreInteractions(mapStringStoragePoolTypeMock, sourceStoragePoolVoMock, destinationStoragePoolVoMock);
442-
}
443375
}

0 commit comments

Comments
 (0)