Skip to content

Block volume shrink on Xen #11004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@

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));

Check warning on line 53 in plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixResizeVolumeCommandWrapper.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixResizeVolumeCommandWrapper.java#L53

Added line #L53 was not covered by tests
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");

Check warning on line 57 in plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixResizeVolumeCommandWrapper.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixResizeVolumeCommandWrapper.java#L56-L57

Added lines #L56 - L57 were not covered by tests
}
if (command.isManaged()) {
resizeSr(conn, command);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2429,6 +2429,9 @@
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 warning on line 2433 in server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L2433 was not covered by tests
}
}
}
/* Check resource limit for this account */
Expand Down
2 changes: 1 addition & 1 deletion ui/src/views/storage/ChangeOfferingForVolume.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down