Block volume shrink on Xen (#11004)

Co-authored-by: João Jandre <joao@scclouds.com.br>
This commit is contained in:
João Jandre 2025-06-24 09:23:57 -03:00 committed by GitHub
parent 75147b7811
commit ba0204f8ed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 3 deletions

View File

@ -49,9 +49,12 @@ public final class CitrixResizeVolumeCommandWrapper extends CommandWrapper<Resiz
try {
if (command.getCurrentSize() >= newSize) {
logger.info("No need to resize volume: " + volId +", current size " + toHumanReadableSize(command.getCurrentSize()) + " is same as new size " + toHumanReadableSize(newSize));
if (command.getCurrentSize() == newSize) {
logger.info("No need to resize volume [{}], current size [{}] is same as new size [{}].", volId, toHumanReadableSize(command.getCurrentSize()), toHumanReadableSize(newSize));
return new ResizeVolumeAnswer(command, true, "success", newSize);
} else if (command.getCurrentSize() > newSize) {
logger.error("XenServer does not support volume shrink. Volume [{}] current size [{}] is smaller than new size [{}]", volId, toHumanReadableSize(command.getCurrentSize()), toHumanReadableSize(newSize));
return new ResizeVolumeAnswer(command, false, "operation not supported");
}
if (command.isManaged()) {
resizeSr(conn, command);

View File

@ -2429,6 +2429,9 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
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.");
}
if (ApiDBUtils.getHypervisorTypeFromFormat(volume.getDataCenterId(), volume.getFormat()) == HypervisorType.XenServer) {
throw new InvalidParameterValueException("Shrink volume is not supported for the XenServer hypervisor.");
}
}
}
/* Check resource limit for this account */

View File

@ -90,7 +90,7 @@
:checked="autoMigrate"
@change="val => { autoMigrate = val }"/>
</a-form-item>
<a-form-item name="shrinkOk" ref="shrinkOk" :label="$t('label.shrinkok')">
<a-form-item name="shrinkOk" ref="shrinkOk" :label="$t('label.shrinkok')" v-if="!['XenServer'].includes(resource.hypervisor)">
<a-switch
v-model:checked="form.shrinkOk"
:checked="shrinkOk"