From 0f0c6ac0bc5f7aa3a37542f6df97e705d69c8e56 Mon Sep 17 00:00:00 2001 From: Slavka Peleva Date: Tue, 20 Jul 2021 14:50:52 +0300 Subject: [PATCH 1/2] Fix of shrinking volumes with QCOW2 format If the volumes are with QCOW2 format the shrinking will be handled on the agents side. There are cases in some storage plugins where the volumes' format is kept in the DB in QCOW2 but the actual format is raw. Till the current implementation this was limiting the plugins to shrink the volumes. Now this will be handled by the storage plugins --- .../java/com/cloud/storage/VolumeApiServiceImpl.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java index ccb91f180edd..9516eb5c6301 100644 --- a/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java +++ b/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java @@ -1063,14 +1063,6 @@ public VolumeVO resizeVolume(ResizeVolumeCmd cmd) throws ResourceAllocationExcep * This will be checked again at the hypervisor level where we can see * the actual disk size. */ - if (currentSize > newSize) { - VolumeVO vol = _volsDao.findById(cmd.getEntityId()); - if (vol != null && ImageFormat.QCOW2.equals(vol.getFormat()) && !Volume.State.Allocated.equals(volume.getState())) { - String message = "Unable to shrink volumes of type QCOW2"; - s_logger.warn(message); - throw new InvalidParameterValueException(message); - } - } if (currentSize > newSize && !shrinkOk) { throw new InvalidParameterValueException("Going from existing size of " + currentSize + " to size of " + newSize + " would shrink the volume." + "Need to sign off by supplying the shrinkok parameter with value of true."); @@ -1323,7 +1315,7 @@ private VolumeVO orchestrateResizeVolume(long volumeId, long currentSize, long n return volume; } catch (Exception e) { - throw new CloudRuntimeException("Exception caught during resize volume operation of volume UUID: " + volume.getUuid(), e); + throw new CloudRuntimeException(String.format("Failed to resize volume operation of volume UUID: [%s] due to - %s", volume.getUuid(), e.getMessage())); } } From 7cdba5f7aeb303f95459dcc28c7de0838df5d402 Mon Sep 17 00:00:00 2001 From: Slavka Peleva Date: Mon, 26 Jul 2021 13:33:39 +0300 Subject: [PATCH 2/2] Addressed @nvazquez suggested change Will log the exception instead the exception message --- .../src/main/java/com/cloud/storage/VolumeApiServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java index 9516eb5c6301..9791267f4984 100644 --- a/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java +++ b/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java @@ -1315,7 +1315,7 @@ private VolumeVO orchestrateResizeVolume(long volumeId, long currentSize, long n return volume; } catch (Exception e) { - throw new CloudRuntimeException(String.format("Failed to resize volume operation of volume UUID: [%s] due to - %s", volume.getUuid(), e.getMessage())); + throw new CloudRuntimeException(String.format("Failed to resize volume operation of volume UUID: [%s] due to - %s", volume.getUuid(), e.getMessage()), e); } }