Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -3201,6 +3201,7 @@
VMInstanceVO vm = null;
if (instanceId != null) {
vm = _vmInstanceDao.findById(instanceId);
checkVmStateForMigration(vm, vol);

Check warning on line 3204 in server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java#L3204

Added line #L3204 was not covered by tests
}

// Check that Vm to which this volume is attached does not have VM Snapshots
Expand Down Expand Up @@ -3398,6 +3399,22 @@
return orchestrateMigrateVolume(vol, destPool, liveMigrateVolume, newDiskOffering);
}

private void checkVmStateForMigration(VMInstanceVO vm, VolumeVO vol) {
List<State> suitableVmStatesForMigration = List.of(State.Stopped, State.Running, State.Shutdown);

Check warning on line 3403 in server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java#L3402-L3403

Added lines #L3402 - L3403 were not covered by tests

if (!suitableVmStatesForMigration.contains(vm.getState())) {
s_logger.debug(String.format(

Check warning on line 3406 in server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java#L3406

Added line #L3406 was not covered by tests
"Unable to migrate volume: [%s] Id: [%s] because the VM: [%s] Id: [%s] is in state [%s], which is not supported for migration.",
vol.getName(), vol.getId(), vm.getInstanceName(), vm.getUuid(), vm.getState()

Check warning on line 3408 in server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java#L3408

Added line #L3408 was not covered by tests
));

throw new CloudRuntimeException(String.format(

Check warning on line 3411 in server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java#L3411

Added line #L3411 was not covered by tests
"Volume migration is not allowed when the VM is in the %s state. Supported states are: %s.",
vm.getState(), suitableVmStatesForMigration

Check warning on line 3413 in server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java#L3413

Added line #L3413 was not covered by tests
));
}
}

Check warning on line 3416 in server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java#L3416

Added line #L3416 was not covered by tests

private boolean isSourceOrDestNotOnStorPool(StoragePoolVO storagePoolVO, StoragePoolVO destinationStoragePoolVo) {
return storagePoolVO.getPoolType() != Storage.StoragePoolType.StorPool
|| destinationStoragePoolVo.getPoolType() != Storage.StoragePoolType.StorPool;
Expand Down
Loading