Skip to content

Commit b090bcd

Browse files
author
Mike Tutkowski
committed
If resizeVolume is invoked while changing a stopped VM’s compute offering, do not throw an exception related to volume resizing if only performance parameters are being changed.
1 parent 9fa2e58 commit b090bcd

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -856,10 +856,10 @@ protected VolumeVO createVolumeFromSnapshot(VolumeVO volume, long snapshotId, Lo
856856
@DB
857857
@ActionEvent(eventType = EventTypes.EVENT_VOLUME_RESIZE, eventDescription = "resizing volume", async = true)
858858
public VolumeVO resizeVolume(ResizeVolumeCmd cmd) throws ResourceAllocationException {
859-
Long newSize = null;
860-
Long newMinIops = null;
861-
Long newMaxIops = null;
862-
Integer newHypervisorSnapshotReserve = null;
859+
Long newSize;
860+
Long newMinIops;
861+
Long newMaxIops;
862+
Integer newHypervisorSnapshotReserve;
863863
boolean shrinkOk = cmd.getShrinkOk();
864864

865865
VolumeVO volume = _volsDao.findById(cmd.getEntityId());
@@ -876,13 +876,6 @@ public VolumeVO resizeVolume(ResizeVolumeCmd cmd) throws ResourceAllocationExcep
876876
/* Does the caller have authority to act on this volume? */
877877
_accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, true, volume);
878878

879-
if(volume.getInstanceId() != null) {
880-
// Check that Vm to which this volume is attached does not have VM Snapshots
881-
if (_vmSnapshotDao.findByVm(volume.getInstanceId()).size() > 0) {
882-
throw new InvalidParameterValueException("Volume cannot be resized which is attached to VM with VM Snapshots");
883-
}
884-
}
885-
886879
DiskOfferingVO diskOffering = _diskOfferingDao.findById(volume.getDiskOfferingId());
887880
DiskOfferingVO newDiskOffering = null;
888881

@@ -1007,6 +1000,13 @@ public VolumeVO resizeVolume(ResizeVolumeCmd cmd) throws ResourceAllocationExcep
10071000

10081001
// if the caller is looking to change the size of the volume
10091002
if (currentSize != newSize) {
1003+
if (volume.getInstanceId() != null) {
1004+
// Check that VM to which this volume is attached does not have VM snapshots
1005+
if (_vmSnapshotDao.findByVm(volume.getInstanceId()).size() > 0) {
1006+
throw new InvalidParameterValueException("A volume that is attached to a VM with any VM snapshots cannot be resized.");
1007+
}
1008+
}
1009+
10101010
if (!validateVolumeSizeRange(newSize)) {
10111011
throw new InvalidParameterValueException("Requested size out of range");
10121012
}

0 commit comments

Comments
 (0)