Skip to content

Commit 446337b

Browse files
authored
Fix of shrinking volumes with QCOW2 format (#5225)
* 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 * Addressed @nvazquez suggested change Will log the exception instead the exception message
1 parent 29090fe commit 446337b

1 file changed

Lines changed: 1 addition & 9 deletions

File tree

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,14 +1063,6 @@ public VolumeVO resizeVolume(ResizeVolumeCmd cmd) throws ResourceAllocationExcep
10631063
* This will be checked again at the hypervisor level where we can see
10641064
* the actual disk size.
10651065
*/
1066-
if (currentSize > newSize) {
1067-
VolumeVO vol = _volsDao.findById(cmd.getEntityId());
1068-
if (vol != null && ImageFormat.QCOW2.equals(vol.getFormat()) && !Volume.State.Allocated.equals(volume.getState())) {
1069-
String message = "Unable to shrink volumes of type QCOW2";
1070-
s_logger.warn(message);
1071-
throw new InvalidParameterValueException(message);
1072-
}
1073-
}
10741066
if (currentSize > newSize && !shrinkOk) {
10751067
throw new InvalidParameterValueException("Going from existing size of " + currentSize + " to size of " + newSize + " would shrink the volume."
10761068
+ "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
13231315
return volume;
13241316

13251317
} catch (Exception e) {
1326-
throw new CloudRuntimeException("Exception caught during resize volume operation of volume UUID: " + volume.getUuid(), e);
1318+
throw new CloudRuntimeException(String.format("Failed to resize volume operation of volume UUID: [%s] due to - %s", volume.getUuid(), e.getMessage()), e);
13271319
}
13281320
}
13291321

0 commit comments

Comments
 (0)