Vered Volansky has uploaded a new change for review. Change subject: core: Disallow RO disks resize in CDA ......................................................................
core: Disallow RO disks resize in CDA Resizing RO disks is now disallowed in UpdateVmDiskCommad.validateCanResizeDisk(), which is called by CDA. Added VdcBllMessages.ACTION_TYPE_FAILED_CANNOT_RESIZE_READ_ONLY_DISK and relevant test. Change-Id: Ibd1b9ec592cacab0156bdede6081b375b7dae935 Bug-Url: https://bugzilla.redhat.com/1092087 Bug-Url: https://bugzilla.redhat.com/1092371 Signed-off-by: Vered Volansky <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmDiskCommand.java M backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVmDiskCommandTest.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties M frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java M frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties M frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties 7 files changed, 35 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/64/27264/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmDiskCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmDiskCommand.java index 4224bae..d219e03 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmDiskCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmDiskCommand.java @@ -267,6 +267,10 @@ protected boolean validateCanResizeDisk() { DiskImage newDiskImage = (DiskImage) getNewDisk(); + if (Boolean.TRUE.equals(getVmDeviceForVm().getIsReadOnly())) { + return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_CANNOT_RESIZE_READ_ONLY_DISK); + } + if (vmDeviceForVm.getSnapshotId() != null) { DiskImage snapshotDisk = getDiskImageDao().getDiskSnapshotForVmSnapshot(getParameters().getDiskId(), vmDeviceForVm.getSnapshotId()); if (snapshotDisk.getSize() != newDiskImage.getSize()) { @@ -591,6 +595,10 @@ return oldDisk; } + protected VmDevice getVmDeviceForVm() { + return vmDeviceForVm; + } + private Disk getNewDisk() { return getParameters().getDiskInfo(); } diff --git a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVmDiskCommandTest.java b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVmDiskCommandTest.java index f5b74bc..bf0d88b 100644 --- a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVmDiskCommandTest.java +++ b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVmDiskCommandTest.java @@ -461,6 +461,26 @@ ("wrong failure", command, VdcBllMessages.ACTION_TYPE_FAILED_REQUESTED_DISK_SIZE_IS_TOO_SMALL); } + @Test + public void testFailedRoDiskResize() { + StorageDomain sd = new StorageDomain(); + sd.setAvailableDiskSize(Integer.MAX_VALUE); + sd.setStatus(StorageDomainStatus.Active); + when(storageDomainDao.getForStoragePool(sdId, spId)).thenReturn(sd); + + UpdateVmDiskParameters parameters = createParameters(); + ((DiskImage) parameters.getDiskInfo()).setSize(parameters.getDiskInfo().getSize() * 2); + initializeCommand(parameters); + + VmDevice device = createVmDevice(diskImageGuid, vmId); + device.setIsReadOnly(true); + doReturn(device).when(command).getVmDeviceForVm(); + + assertFalse(command.validateCanResizeDisk()); + CanDoActionTestUtils.assertCanDoActionMessages + ("wrong failure", command, VdcBllMessages.ACTION_TYPE_FAILED_CANNOT_RESIZE_READ_ONLY_DISK); + } + private void initializeCommand(UpdateVmDiskParameters params) { initializeCommand(params, Collections.singletonList(createVmStatusDown())); } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java index 4b6173e..0eeaff9 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java @@ -766,6 +766,7 @@ ACTION_TYPE_FAILED_NO_DISKS_SPECIFIED(ErrorType.BAD_PARAMETERS), ACTION_TYPE_FAILED_SOURCE_AND_TARGET_SAME(ErrorType.BAD_PARAMETERS), ACTION_TYPE_FAILED_REQUESTED_DISK_SIZE_IS_TOO_SMALL(ErrorType.BAD_PARAMETERS), + ACTION_TYPE_FAILED_CANNOT_RESIZE_READ_ONLY_DISK(ErrorType.CONFLICT), ACTION_TYPE_FAILED_CANNOT_RESIZE_DISK_SNAPSHOT(ErrorType.CONFLICT), NON_VM_NETWORK_NOT_SUPPORTED_FOR_POOL_LEVEL(ErrorType.NOT_SUPPORTED), VALIDATION_STORAGE_CONNECTION_INVALID(ErrorType.BAD_PARAMETERS), diff --git a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties index 99b0510..a3194a2 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties @@ -242,6 +242,7 @@ ACTION_TYPE_FAILED_TEMPLATE_NOT_FOUND_ON_DESTINATION_DOMAIN=Cannot ${action} ${type}. The selected Storage Domain does not contain the VM Template. ACTION_TYPE_FAILED_NO_VDS_IN_POOL=Cannot ${action} ${type}. There is no active Host in the Data Center. ACTION_TYPE_FAILED_REQUESTED_DISK_SIZE_IS_TOO_SMALL=Cannot ${action} ${type} size. New disk size must be larger than current disk size. +ACTION_TYPE_FAILED_CANNOT_RESIZE_READ_ONLY_DISK=Cannot ${action} ${type}. Read-only disk cannot be resized. ACTION_TYPE_FAILED_CLOUD_INIT_IS_NOT_SUPPORTED=Cannot ${action} ${type}. Cloud-Init is only supported on cluster compatibility version 3.3 and higher. ACTION_TYPE_FAILED_CANNOT_RESIZE_DISK_SNAPSHOT=Cannot ${action} ${type}. Disk snapshot cannot be resized. VAR__TYPE__HOST=$type Host diff --git a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java index f11e863..993a707 100644 --- a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java +++ b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java @@ -2946,6 +2946,9 @@ @DefaultStringValue("Cannot ${action}. New disk size cannot be smaller than the current.") String ACTION_TYPE_FAILED_REQUESTED_DISK_SIZE_IS_TOO_SMALL(); + @DefaultStringValue("Cannot ${action} ${type}. Read-only disk cannot be resized.") + String ACTION_TYPE_FAILED_CANNOT_RESIZE_READ_ONLY_DISK(); + @DefaultStringValue("Cannot ${action} ${type}. Disk snapshot cannot be resized.") String ACTION_TYPE_FAILED_CANNOT_RESIZE_DISK_SNAPSHOT(); diff --git a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties index 59488d5..2f0b5e9 100644 --- a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties +++ b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties @@ -238,6 +238,7 @@ ACTION_TYPE_FAILED_TEMPLATE_NOT_FOUND_ON_DESTINATION_DOMAIN=Cannot ${action} ${type}. The selected Storage Domain does not contain the VM Template. ACTION_TYPE_FAILED_NO_VDS_IN_POOL=Cannot ${action} ${type}. There is no active Host in the Data Center. ACTION_TYPE_FAILED_REQUESTED_DISK_SIZE_IS_TOO_SMALL=Cannot ${action}. New disk size must be larger than current disk size. +ACTION_TYPE_FAILED_CANNOT_RESIZE_READ_ONLY_DISK=Cannot ${action} ${type}. Read-only disk cannot be resized. ACTION_TYPE_FAILED_CANNOT_RESIZE_DISK_SNAPSHOT=Cannot ${action} ${type}. Disk snapshot cannot be resized. ACTION_TYPE_FAILED_ILLEGAL_DISK_OPERATION=Cannot ${action} ${type}. Disk is in illegal state. Illegal disks can only be deleted. ACTION_TYPE_FAILED_CLOUD_INIT_IS_NOT_SUPPORTED=Cannot ${action} ${type}. Cloud-Init is only supported on cluster compatibility version 3.3 and higher. diff --git a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties index f8c7d04..b328e9f 100644 --- a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties +++ b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties @@ -240,6 +240,7 @@ ACTION_TYPE_FAILED_TEMPLATE_NOT_FOUND_ON_DESTINATION_DOMAIN=Cannot ${action} ${type}. The selected Storage Domain does not contain the VM Template. ACTION_TYPE_FAILED_NO_VDS_IN_POOL=Cannot ${action} ${type}. There is no active Host in the Data Center. ACTION_TYPE_FAILED_REQUESTED_DISK_SIZE_IS_TOO_SMALL=Cannot ${action} ${type}. New disk size must be larger than current disk size. +ACTION_TYPE_FAILED_CANNOT_RESIZE_READ_ONLY_DISK=Cannot ${action} ${type}. Read-only disk cannot be resized. ACTION_TYPE_FAILED_CLOUD_INIT_IS_NOT_SUPPORTED=Cannot ${action} ${type}. Cloud-Init is only supported on cluster compatibility version 3.3 and higher. ACTION_TYPE_FAILED_CANNOT_RESIZE_DISK_SNAPSHOT=Cannot ${action} ${type}. Disk snapshot cannot be resized. VAR__TYPE__HOST=$type Host -- To view, visit http://gerrit.ovirt.org/27264 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ibd1b9ec592cacab0156bdede6081b375b7dae935 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.4 Gerrit-Owner: Vered Volansky <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
