vmware / vmware/pyvmomi

Destroy VM task leaves garbage on datastore when creating Virtual Disk

Open
#541 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs verification
Dominant language
Python
Stars
2.3k
Forks
763
PR merge metrics
No merged PRs in 30d

Description

Below is the code used for adding a virtualdisk to a virtual machine:

-----------------------------------snippet-----------------------------------------
disk_spec = vim.vm.device.VirtualDeviceSpec()
disk_spec.fileOperation = "create"
disk_spec.operation = vim.vm.device.VirtualDeviceSpec.Operation.add
disk_spec.device = vim.vm.device.VirtualDisk()
disk_spec.device.backing = vim.vm.device.VirtualDisk.FlatVer2BackingInfo()
disk_spec.device.backing.thinProvisioned = True
disk_spec.device.backing.diskMode = 'persistent'
disk_spec.device.unitNumber = unit_number
my_disk.port = unit_number
disk_spec.device.capacityInKB = int(disk.size) * 1024 * 1024
disk_spec.device.controllerKey = controller.key
dev_changes.append(disk_spec)
spec.deviceChange = dev_changes
configure_disk_task = vm.ReconfigVM_Task(spec=spec)
-----------------------------------snippet-----------------------------------------

After the destroy VM task is completed, still files are lingering around on the data store, and therefore the datastore cannot delete the folders, which it keeps piling up:

[root@esx2:/vmfs/volumes/58aca8b7-0bf10598-21ff-0cc47a80f82a/kalipso_3] ls -ltrah
total 1032
-rw------- 1 root root 0 Apr 14 10:02 kalipso_3.vmdk
-rw------- 1 root root 0 Apr 14 10:02 kalipso_2.vmdk
-rw------- 1 root root 0 Apr 14 10:02 kalipso_1.vmdk
drwxr-xr-x 1 root root 700 Apr 14 10:03 .
drwxr-xr-t 1 root root 3.7K Apr 14 14:12 ..

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reported vm.ReconfigVM_Task call and the subsequent destroy VM task, using the provided virtual-disk configuration and datastore listing to reproduce the behavior. Done means destroying the VM no longer leaves the zero-byte VMDK files behind and the datastore folder can be deleted.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend-api-design, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.