Skip to content

Commit

Permalink
fix(esxi): Detach all disk first when deleting vm
Browse files Browse the repository at this point in the history
  • Loading branch information
rainzm committed May 21, 2020
1 parent ff2fc74 commit 9bb7320
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/multicloud/esxi/virtualmachine.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,13 @@ func (self *SVirtualMachine) shutdownVM(ctx context.Context) error {

func (self *SVirtualMachine) doDelete(ctx context.Context) error {
vm := self.getVmObj()
// detach all disks first
for i := range self.vdisks {
err := self.doDetachAndDeleteDisk(ctx, &self.vdisks[i])
if err != nil {
return errors.Wrap(err, "doDetachAndDeteteDisk")
}
}

task, err := vm.Destroy(ctx)
if err != nil {
Expand Down

0 comments on commit 9bb7320

Please sign in to comment.