Skip to content

fix(vmbda): stuck in InProgress when cloning VM with hotplug disks#2080

Open
danilrwx wants to merge 1 commit intomainfrom
fix/vmbda-clone-hotplug-disks
Open

fix(vmbda): stuck in InProgress when cloning VM with hotplug disks#2080
danilrwx wants to merge 1 commit intomainfrom
fix/vmbda-clone-hotplug-disks

Conversation

@danilrwx
Copy link
Contributor

@danilrwx danilrwx commented Mar 6, 2026

Description

Fix VMBDA (VirtualMachineBlockDeviceAttachment) stuck in InProgress when cloning a VM with hotplug disks.

Root cause: when cloning a VM, getVirtualDisks() set AttachedToVirtualMachines to the original VM name from vmSnapshot.Spec.VirtualMachineName. This caused WaitForFirstConsumer logic to bypass correctly since len(AttachedToVirtualMachines)==1.

Fix:

  • snapshot_resources.go: pass operation type to getVirtualDisks() and only set AttachedToVirtualMachines for restore operation. For clone, leave it empty so WaitForFirstConsumer logic works correctly.
  • vd_restorer.go: update AttachedToVirtualMachines in Customize() method for defense in depth.

Why do we need it, and what problem does it solve?

When a user attempts to clone a VirtualMachine that has hotplug disks attached, the VMBDA resource gets stuck in InProgress phase indefinitely. This blocks the clone operation from completing.

The root cause is that during clone operations, the code was setting AttachedToVirtualMachines in the VirtualDisk status to the original VM's name. This triggered the WaitForFirstConsumer storage binding logic to immediately bind the PVC to the original VM (since there's 1 entry in the list), rather than waiting for the cloned VM to attach the disk.

What is the expected result?

  1. Clone a VM with hotplug disks
  2. VMBDA should complete successfully and transition to InUse phase
  3. Cloned VM should have access to the disks

Checklist

  • The code is covered by unit tests.
  • e2e tests passed.
  • Documentation updated according to the changes.
  • Changes were tested in the Kubernetes cluster manually.

Changelog entries

section: core
type: fix
summary: Fix VMBDA stuck in InProgress when cloning VM with hotplug disks.
impact_level: low

…g disks

Root cause: when cloning a VM, getVirtualDisks() set AttachedToVirtualMachines
to the original VM name from vmSnapshot.Spec.VirtualMachineName. This caused
WaitForFirstConsumer logic to bypass correctly since len(AttachedToVirtualMachines)==1.

Fix:
- snapshot_resources.go: pass operation type to getVirtualDisks() and only set
  AttachedToVirtualMachines for restore operation. For clone, leave it empty
  so WaitForFirstConsumer logic works correctly.
- vd_restorer.go: update AttachedToVirtualMachines in Customize() method for
  defense in depth.

Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
@danilrwx danilrwx added this to the v1.7.0 milestone Mar 6, 2026
@danilrwx danilrwx changed the title fix(vmbda): fix VMBDA stuck in InProgress when cloning VM with hotplu… fix(vmbda): stuck in InProgress when cloning VM with hotplug disks Mar 6, 2026
@danilrwx danilrwx marked this pull request as ready for review March 6, 2026 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant