vmware / govmomi

Go library for the VMware vSphere API
Apache License 2.0
2.26k stars 896 forks source link

[BUG] Invalid operation for device '0' in 0.37.2 #3441

Open fpiecka opened 1 month ago

fpiecka commented 1 month ago

Describe the bug Unable to expand disk in version 0.37.2.

0.37.1 works.

To Reproduce Steps to reproduce the behavior:

  1. podman run --rm -it -e GOVC_URL -e GOVC_USERNAME -e GOVC_PASSWORD vmware/govc:v0.37.2 /govc vm.disk.change -vm "${VM_NAME}" -disk.key 2000 -size "20G"
  2. Output of the command:
    /govc: error resizing main disk
    Logged Item:  Invalid operation for device '0'.
  3. Do the same with v0.37.1 and the disk will be resized without an error.

Expected behavior Disk should be resized.

Affected version 0.37.2 is affected and anything older works. I expect the problem is with commit e6fe159bf77e743d815f2204598f53f1b1d21b7c.

Screenshots/Debug Output

I think the problem is the difference in the following SOAP call. Everything else in the trace output seems the same.

$ diff -u --color /tmp/x1 /tmp/x2
--- /tmp/x1     2024-05-17 14:26:28.835915920 +0200
+++ /tmp/x2     2024-05-17 14:26:38.166031057 +0200
@@ -28,7 +28,7 @@
                         </backing>
                         <controllerKey>1000</controllerKey>
                         <unitNumber>0</unitNumber>
-                        <capacityInKB>36700160</capacityInKB>
+                        <capacityInKB>0</capacityInKB>
                         <capacityInBytes>37580963840</capacityInBytes>
                         <shares>
                             <shares>1000</shares>

Additional context vCenter version: 8.0.2.00100 (Build: 22617221)

github-actions[bot] commented 1 month ago

Howdy 🖐   fpiecka ! Thank you for your interest in this project. We value your feedback and will respond soon.

If you want to contribute to this project, please make yourself familiar with the CONTRIBUTION guidelines.

abhay-krishna commented 1 month ago

@fpiecka We also faced the same issue. We were also previously using v0.37.1 which was successful, but when we switched to v0.37.2, the disk resize started failing. We are currently working around it with a patch to govmomi, that reverts setting the capacityInKB value to 0. So I believe deprecating capacityInKB by setting it to 0 (as is being done in https://github.com/vmware/govmomi/commit/e6fe159bf77e743d815f2204598f53f1b1d21b7c) has some unintended consequences.